Changing file names automatically
Changing file names automatically
Author
Discussion

trackdemon

Original Poster:

13,449 posts

291 months

Wednesday 30th November 2005
quotequote all
I'm sure there's a relatively straightforward way of doing this, but it sure isn't something I've done before....

I've got a bunch of files called *for example*:

filename_morefilename.jpg

I want to change the filenames to:

filename_date_morefilename.jpg

But there are almost 200 files, so I'd like to do it using windows scripting or batch file - can it be done, and if so does anyone know how? A virtual beer (or a real one if your near me!) and many thanks to the winner!!

ErnestM

11,621 posts

297 months

Wednesday 30th November 2005
quotequote all
If they are all pictures, Photshop can do it (if you have it).

ErnestM

tycho

12,285 posts

303 months

Wednesday 30th November 2005
quotequote all
Could do a dir into a file and then open it in excel which would allow you to concatenate and split filenames, then put into notepad and save as a batch file. Maybe a long way of doing it but this is what I did with a load of MP3s which needed the track numbers removing.

dilbert

7,741 posts

261 months

Wednesday 30th November 2005
quotequote all
I'm thinking that you want to use the "VBA FileSystem" object to copy the files to a new location, under the new name, then, all you have to do manually is to check it did it OK, delete the old files, and copy the new ones back to where the old ones were.

Use MS excel, open up the macro editor, and launch the object browser and do a search on FileSystem.

Unless you actually have a standalone copy of VB, it's a great way of writing and debugging VB, which under XP you can then run directly from the command line.

arcturus

1,498 posts

293 months

Wednesday 30th November 2005
quotequote all
Or you could use the Magic File Renamer

I have been using this tool for many years for automating renaming tasks. Beware, it is very powerful and you may get some unintended results if you are not careful.

You can get a free demo of the current version or if you click the previous versions button on the left of the page, you can pick up the free version.

trackdemon

Original Poster:

13,449 posts

291 months

Wednesday 30th November 2005
quotequote all
tycho said:
Could do a dir into a file and then open it in excel which would allow you to concatenate and split filenames, then put into notepad and save as a batch file. Maybe a long way of doing it but this is what I did with a load of MP3s which needed the track numbers removing.


Did it quick and dirty way:

dir >filenames.txt

open in excel space delimited, remove unwanted rubbish and create extra columns around the original filename list, in col 1 "ren", col 3 "filename + required text added using ctrl+h". Save then open text file in notepad, ctrl+H replace the tab spaces with normal spaces and resave as filename.bat. Run! Works fine!

trackdemon

Original Poster:

13,449 posts

291 months

Thursday 1st December 2005
quotequote all
arcturus said:
Or you could use the Magic File Renamer

I have been using this tool for many years for automating renaming tasks. Beware, it is very powerful and you may get some unintended results if you are not careful.

You can get a free demo of the current version or if you click the previous versions button on the left of the page, you can pick up the free version.


Downloaded - used! Explorer seems a little unstable now though.

zumbruk

7,848 posts

290 months

Thursday 1st December 2005
quotequote all
There's also a perl program called (astonishingly) "rename" which allows you to apply a perl regular expression to a list of filenames, like;

rename 's/from/to/;' *.txt

jimothy

5,151 posts

267 months

Thursday 1st December 2005
quotequote all
This is what I love about IT...
Ask 100 IT bods how to solve a problem, and you'll get 200 solutions...

docevi1

10,430 posts

278 months

Thursday 1st December 2005
quotequote all

zumbruk

7,848 posts

290 months

Thursday 1st December 2005
quotequote all
jimothy said:
This is what I love about IT...
Ask 100 IT bods how to solve a problem, and you'll get 200 solutions...


More like 37 solutions, 43 people who misunderstand the question, 17 who answer a completely unrelated question, 26 who say you shouldn't be doing it like that, 12 who say you should be using a Mac/Linux/Windows Vista/VMS/MVS-XP instead, 13 people selling porn, viagra and "college degrees" and a request to launder $30M for Sonny Abacha's son/widow/chaffeur.

(Yes, I know it doesn't add up. The classes overlap...)

trackdemon

Original Poster:

13,449 posts

291 months

Friday 2nd December 2005
quotequote all
Does anyone have a copy of Magic File renamer I could pilfer in exchange for a beer? Seems a good tool

LongQ

13,864 posts

263 months

Saturday 3rd December 2005
quotequote all
Option number 101 ....

Try this little freebie.

I haven't used it much - found it when seeking a solution for someone else - but it works well in testing and I can see a need coming up for renaming several thousand photos ...

He also does some other rather useful utilities.

www.fauland.com/af5.htm

Jonny5

3,526 posts

304 months

Tuesday 6th December 2005
quotequote all


Simple in unix - e.g old filenames are DSCxxxxx.jpg new are Ferrarixxxxx.jpg

for i in `ls *.jpg`
do
NEW=`echo $i | sed -e 's/^DSC/Ferrari/g'`
mv ${i} ${NEW}
done