|I am trying to setup a batch script to automate the following process: I have a directory with several files (could be 2, could be hundreds) all named *.1. *.2, *.3, *.11, *.123. I need to join these files together but not in 1, 11, 123, 2, 3, order. I need to rename the .1 to .0001 and the .11 to .0011 and the .123 to .0123. I have been working with iterations of the FOR command for the past day and a half and I just can't get it right. Can anyone point me in the right direction? Here is the code I currently have. It is expanded a bit to help me troubleshoot...|
For /f "tokens=* delims=" %%I in ('dir /a-d /b *.*') do (set str=%%~xI & set str2=000%str% & set str3=%str2:.=0% & set str4=%str3:~-4% & rename "%%~I" "%%~nI.%str4%")
My thinking is grab the extension (.1), add zeros (000.1), replace . with 0 (00001), take right 4 digits, (0001), rename to original file + . + new extension (filename.0001). Is there an easier way (or a way that works)? I am familiar with DOS, but I haven't done a lot in years, and I have never used the FOR command to this extent before. Thanks for nay help you can provide!