AnsweredAssumed Answered

Batch File to Rename .DWG's

Question asked by James Donnellan on Apr 1, 2014
Latest reply on Apr 1, 2014 by Deepak Gupta

I have adapted a relatively generic batch file that I came across on the Internet to rename .DWG's that are exported through task scheduler. I have attached the script below. basically it removes the __1 that is placed at the end of the DWG file name, this one here only works for __1 but where there are 2 or more sheets in a drawing it names them __2, __3 etc. where I work we rarely have 2 sheets in a drawing file and I haven't come across a need for 3 sheets in a drawing file yet, however i would like to modify the script so it would rename a __2 down to an __1 and __3 down to an __2.


I have tried a few different things to no avail so any help would be appreciated.





@echo off

setlocal enabledelayedexpansion

set deletestring=__1

echo Ready to start




for /f "delims==" %%F in ('dir /b ^| find "%deletestring%"') do (

          set oldfilename=%%F

          set newfilename=!oldfilename:%deletestring%=!

          Ren "!oldfilename!" "!newfilename!"



echo All done