ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Easy way to rename a file using the contents of a text file in batch or script

(1/2) > >>

questorfla:
For example.  I need to rename a file photo.jpg using the contents of a text file "whose.txt". 
In all cases, the text file will only contain one word with no special characters or spaces only normal alphabetic letters. 
For example: whose.txt could be the word "mypicture".  Running the script would rename photo.jpg to mypicture.jpg and do it even if it overwrites an existing file with the name "mypicture.jpg".

I know this is probably something simple but it is late i can't think :(
I tried to set a variable to the contents of the text file then use the variable to rename the jpg file but can't get things in the right order to work.

tomos:
Not exactly what you're looking for, but may be of interest:

Hi all,
How could I do the following?
I have a folder with files and a text file with a list of names (actually it's a spreadsheet with two columns)
What I'd want to do is to drag and drop each file to a listbox so it gets renamed
-kilele (December 22, 2016, 01:17 AM)
--- End quote ---

I had to rename a bunch of files using a text list just this week.
Used Oscar's Renamer after a 2006 (!) recommendation here on dc.
it isnt in development, but is still being sold :down:
I used the trial -- it worked on Windows 7 x64
it was very fussy: wouldn't work for a while, I think possibly because of an extra carriage return at the bottom of the list of new names. But it did work in the end.

Also found a couple of sites showing how to do it using spreadsheet (and?). Can check my desktop history later and post link/s.
-tomos (December 22, 2016, 01:53 AM)
--- End quote ---

tomos:
Not exactly what you're looking for, but may be of interest:
-tomos (March 08, 2018, 05:12 AM)
--- End quote ---

actually best go read that thread: there are various other suggestions there

jity2:
Maybe try with Bulk Rename Utility / actions/ import rename pairs (see their help file) + renaming options/prevent duplicates ?

Nod5:
I need to rename a file photo.jpg using the contents of a text file "whose.txt". 
In all cases, the text file will only contain one word with no special characters or spaces only normal alphabetic letters. 
-questorfla (March 07, 2018, 11:08 PM)
--- End quote ---

Do each txt filename have some pattern that link them to a unique original jpg filename? For example the new name for photo.jpg is in photo.txt , the new name for another_picture.jpg in another_picture.txt and so on. Then it would be very easy to make a batch script to handle the renaming.

But if the txt and jpg files have no such matching pattern, like in your whose.txt and photo.jpg example, then I guess the only option is a script that accept two files (the txt and jpg) as input. You'd then manually run that on each txt/jpg pair you have. If you can remember which txt belongs to which jpg that is  ;D

Navigation

[0] Message Index

[#] Next page

Go to full version