1.

Solve : rename batch file?

Answer»

Hi - I'm hoping that someone out there can HELP. I have approx 200 FOLDERS each with a series of files called Tasveg; ie each folder contains Tasveg.shp, Tasveg.dbf, Tasveg.shx etc.

What I need to do is rename each set of files with a unique identifier
Folder A containc TasvegA.shp, TasvegA.dbf, TasvegA.shx etc
Folder B contains TasvegB.shp, TasvegB.dbf, TasvegB.shx etc
Folder C contains TasvegC.shp, TasvegC.dbf, TasvegC.shx etc

Thanks
HelenaI have the actual REN command set to ECHO INSTEAD of rename so you can test first. Be sure you have a backup because bulk renaming can be risky. This assumes no directories or files have spaces in them and they are all in the root of the current directory.

I think you can probably do something like:
Code: [Select]@echo off
echo About to rename a bunch of files ... be sure you have a backup!
pause
for /f %%a in ('dir /ad /b') do echo ren %%a\Tasveg.* Tasveg%%a.*
If you have a backup and it looks like it will work, remove the word "echo" from the line that starts with "for".YEP - I made sure I did a back up before I ran the script

thanks for your help - WORKED a treat

Cheers
Helena



Discussion

No Comment Found