Page 1 of 1

Multi file rename entire directory to a set list of names?

Posted: 29 Nov 2015 21:48
by NewYears1978
This is hard to explain but I currently have a folder full of files that I constantly have to rename to certain names.

Currently I rename all my files with a batch renamer to set filenames that I then run a batch file to rename them, but it's tedious. I would like to be able to rename them to the set names no matter what files I have in there.

Here is my current batch file

Code: Select all

rename MUS001.xwm mus_institute_bach_suiteineminorbwv996.xwm
rename MUS002.xwm mus_institute_brahms_tragicovertureop81.xwm
rename MUS003.xwm mus_institute_camillesaintsaens_carnivalcuckoos.xwm
rename MUS004.xwm mus_institute_camillesaintsaens_carnivalelephants.xwm
rename MUS005.xwm mus_institute_camillesaintsaens_carnivalswan.xwm
rename MUS006.xwm mus_institute_chechova_troipolkasdessalonop7.xwm
rename MUS007.xwm mus_institute_chopin_introductionpolonaisebrillantincmaj.xwm
rename MUS008.xwm mus_institute_chopin_nocturneeflatmajor.xwm
rename MUS009.xwm mus_institute_debussy_lamer.xwm
rename MUS010.xwm mus_institute_debussy_nocturnes1nuages.xwm
rename MUS011.xwm mus_institute_elgar_nimrod.xwm
rename MUS012.xwm mus_institute_elgar_salutdamor.xwm
rename MUS013.xwm mus_institute_grieg_peergyntmorningmood.xwm
rename MUS014.xwm mus_institute_grieg_peergyntmountainking.xwm
rename MUS015.xwm mus_institute_holst_mars.xwm
rename MUS016.xwm mus_institute_liszt_consolationsno3.xwm
rename MUS017.xwm mus_institute_liszt_hungarianrhapsodyno2.xwm
rename MUS018.xwm mus_institute_masson_valsediable.xwm
rename MUS019.xwm mus_institute_moravec_balladingminorop23.xwm
rename MUS020.xwm mus_institute_mussorgsky_gopak.xwm
rename MUS021.xwm mus_institute_mussorgsky_meditation.xwm
rename MUS022.xwm mus_institute_rimskykorsakov_scheherezade.xwm
rename MUS023.xwm mus_institute_scarlatti_sonatainfminor.xwm
rename MUS024.xwm mus_institute_smetana_strqurtetno12eflatmajorop127.xwm
rename MUS025.xwm mus_institute_strauss_bluedanubewaltz.xwm
rename MUS026.xwm mus_institute_tchaikovsky_marcheslave.xwm
rename MUS027.xwm mus_institute_tchaikovsky_swanlakefinale.xwm
rename MUS028.xwm mus_institute_wagner_faustoverture.xwm
rename MUS029.xwm mus_institute_wagner_rideofthevalkyries.xwm


Those renames are always the same but the original names on the left I want it to work no matter what the names are. There is no required order either, there will always be 29 files in the folder and they need to be renamed to the names on the right.

Thanks in advance.

Re: Multi file rename entire directory to a set list of names?

Posted: 30 Nov 2015 07:42
by foxidrive
Give this a test on some files.

Code: Select all

@echo off
for %%a in (
mus_institute_bach_suiteineminorbwv996.xwm
mus_institute_brahms_tragicovertureop81.xwm
mus_institute_camillesaintsaens_carnivalcuckoos.xwm
mus_institute_camillesaintsaens_carnivalelephants.xwm
mus_institute_camillesaintsaens_carnivalswan.xwm
mus_institute_chechova_troipolkasdessalonop7.xwm
mus_institute_chopin_introductionpolonaisebrillantincmaj.xwm
mus_institute_chopin_nocturneeflatmajor.xwm
mus_institute_debussy_lamer.xwm
mus_institute_debussy_nocturnes1nuages.xwm
mus_institute_elgar_nimrod.xwm
mus_institute_elgar_salutdamor.xwm
mus_institute_grieg_peergyntmorningmood.xwm
mus_institute_grieg_peergyntmountainking.xwm
mus_institute_holst_mars.xwm
mus_institute_liszt_consolationsno3.xwm
mus_institute_liszt_hungarianrhapsodyno2.xwm
mus_institute_masson_valsediable.xwm
mus_institute_moravec_balladingminorop23.xwm
mus_institute_mussorgsky_gopak.xwm
mus_institute_mussorgsky_meditation.xwm
mus_institute_rimskykorsakov_scheherezade.xwm
mus_institute_scarlatti_sonatainfminor.xwm
mus_institute_smetana_strqurtetno12eflatmajorop127.xwm
mus_institute_strauss_bluedanubewaltz.xwm
mus_institute_tchaikovsky_marcheslave.xwm
mus_institute_tchaikovsky_swanlakefinale.xwm
mus_institute_wagner_faustoverture.xwm
mus_institute_wagner_rideofthevalkyries.xwm
) do for %%b in (*) do if /i not "%%b"=="%~nx0" if not exist "%%a" ren "%%b" "%%a"

Re: Multi file rename entire directory to a set list of names?

Posted: 30 Nov 2015 10:08
by Aacini

Code: Select all

@echo off
goto Rename

mus_institute_bach_suiteineminorbwv996.xwm
mus_institute_brahms_tragicovertureop81.xwm
mus_institute_camillesaintsaens_carnivalcuckoos.xwm
mus_institute_camillesaintsaens_carnivalelephants.xwm
mus_institute_camillesaintsaens_carnivalswan.xwm
mus_institute_chechova_troipolkasdessalonop7.xwm
mus_institute_chopin_introductionpolonaisebrillantincmaj.xwm
mus_institute_chopin_nocturneeflatmajor.xwm
mus_institute_debussy_lamer.xwm
mus_institute_debussy_nocturnes1nuages.xwm
mus_institute_elgar_nimrod.xwm
mus_institute_elgar_salutdamor.xwm
mus_institute_grieg_peergyntmorningmood.xwm
mus_institute_grieg_peergyntmountainking.xwm
mus_institute_holst_mars.xwm
mus_institute_liszt_consolationsno3.xwm
mus_institute_liszt_hungarianrhapsodyno2.xwm
mus_institute_masson_valsediable.xwm
mus_institute_moravec_balladingminorop23.xwm
mus_institute_mussorgsky_gopak.xwm
mus_institute_mussorgsky_meditation.xwm
mus_institute_rimskykorsakov_scheherezade.xwm
mus_institute_scarlatti_sonatainfminor.xwm
mus_institute_smetana_strqurtetno12eflatmajorop127.xwm
mus_institute_strauss_bluedanubewaltz.xwm
mus_institute_tchaikovsky_marcheslave.xwm
mus_institute_tchaikovsky_swanlakefinale.xwm
mus_institute_wagner_faustoverture.xwm
mus_institute_wagner_rideofthevalkyries.xwm


:Rename
setlocal EnableDelayedExpansion

findstr "^mus_" "%~F0" > newNames.txt
< newNames.txt (
   for %%a in (*.*) do (
      set /P "newName="
      ECHO ren "%%a" "!newName!"
   )
)
del newNames.txt

After you tested that the displayed names are correct, remove the ECHO part in order to execute the REN command.

You may also keep the names in the newNames.txt file and remove the "goto Rename", "findstr ..." and "del newNames.txt" lines from the Batch file.

Antonio

Re: Multi file rename entire directory to a set list of names?

Posted: 30 Nov 2015 18:33
by NewYears1978
Thank you for this I will check it out and report back :)

Re: Multi file rename entire directory to a set list of names?

Posted: 02 Dec 2015 17:06
by foxidrive
Have you reported back yet? ;)