I am very new at batch scripts. In fact this is my first on.
What I have is a directory of various .csv files that were created by a script I use. But they were named incorrectly. I wrote a batch (below) to rename these but it does not work. You will see that I have the correct drive and directory and current name is correct and I want to change to a very similar name but with a different set of numbers (that is the only difference)
Each line I have a different current name and a name of the file I wish it to be but when I run the batch file the cmd window opens and it runs through the list of 400 files (takes about 45 sec) then finishes but the resulting file names do not change.
Here is just a sampling of the batch file syntax. Thanks
ren c:\csvBU\hobbies_&_leisure_10052_cat_photo.csv hobbies_&_leisure_1049_cat_photo.csv
ren c:\csvBU\hobbies_&_leisure_10064_catalog_photography.csv hobbies_&_leisure_1050_catalog_photography.csv
ren c:\csvBU\hobbies_&_leisure_10160_celebrity_stock_photography.csv hobbies_&_leisure_1051_celebrity_stock_photography.csv
ren c:\csvBU\hobbies_&_leisure_10934_cheap_stock_photography.csv hobbies_&_leisure_1052_cheap_stock_photography.csv
ren c:\csvBU\hobbies_&_leisure_11208_chicago_wedding_photography.csv hobbies_&_leisure_1053_chicago_wedding_photography.csv
ren c:\csvBU\hobbies_&_leisure_11474_christian_stock_photography.csv hobbies_&_leisure_1054_christian_stock_photography.csv
ren c:\csvBU\hobbies_&_leisure_11517_cia_stock_photography.csv hobbies_&_leisure_1055_cia_stock_photography.csv
ren c:\csvBU\hobbies_&_leisure_11590_city_photographers.csv hobbies_&_leisure_1056_city_photographers.csv
ren c:\csvBU\hobbies_&_leisure_11659_cleveland_wedding_photography.csv hobbies_&_leisure_1057_cleveland_wedding_photography.csv
ren c:\csvBU\hobbies_&_leisure_11920_coffee_table_photo_book.csv hobbies_&_leisure_1058_coffee_table_photo_book.csv
ren c:\csvBU\hobbies_&_leisure_12291_color_laser_photo_printer.csv hobbies_&_leisure_1059_color_laser_photo_printer.csv
ren c:\csvBU\hobbies_&_leisure_12294_color_photo_printer.csv hobbies_&_leisure_1060_color_photo_printer.csv
ren c:\csvBU\hobbies_&_leisure_12295_color_photo_printers.csv hobbies_&_leisure_1061_color_photo_printers.csv
ren c:\csvBU\hobbies_&_leisure_12296_color_photography.csv hobbies_&_leisure_1062_color_photography.csv
ren c:\csvBU\hobbies_&_leisure_12301_color_printer_photo.csv hobbies_&_leisure_1063_color_printer_photo.csv
ren c:\csvBU\hobbies_&_leisure_12372_colorado_wedding_photography.csv hobbies_&_leisure_1064_colorado_wedding_photography.csv
ren c:\csvBU\hobbies_&_leisure_12389_columbus_ohio_photographer.csv hobbies_&_leisure_1065_columbus_ohio_photographer.csv
ren c:\csvBU\hobbies_&_leisure_12454_commercial_digital_photography.csv hobbies_&_leisure_1066_commercial_digital_photography.csv
ren c:\csvBU\hobbies_&_leisure_12589_commercial_photography.csv hobbies_&_leisure_1067_commercial_photography.csv
ren c:\csvBU\hobbies_&_leisure_12613_commercial_stock_photography.csv hobbies_&_leisure_1068_commercial_stock_photography.csv
File Renaming
Moderator: DosItHelp
Re: File Renaming
The ampersands have a special meaning in batch files. For that reason it's more difficult to use them in file names.
Either you could escape each of them using a caret ...
... or you could enclose the pathes / file names in quotes ...
Regards
aGerman
Either you could escape each of them using a caret ...
Code: Select all
ren c:\csvBU\hobbies_^&_leisure_10052_cat_photo.csv hobbies_^&_leisure_1049_cat_photo.csv
... or you could enclose the pathes / file names in quotes ...
Code: Select all
ren "c:\csvBU\hobbies_&_leisure_10052_cat_photo.csv" "hobbies_&_leisure_1049_cat_photo.csv"
Regards
aGerman
Re: File Renaming
aGerman, That worked perfectly. I used the quotations (") method. I was able to change 2000 files in about 90 seconds with this solutions. What a real time saver.
Thank you for the help
Thank you for the help