I have only recently started playing with batch files (as you will find out from my messy code :)
I have a bunch of 2D CAD drawing that I have converted over from another program.
I need to rename these files to the company standard.
T12345x3.bog.dxf Should be:
Some of these file names are different in structure and most have bogus extensions prefixing the genuine extensions as seen above.
I have been using the for loop method to sucessfully extract different parts of the filename which I have then pieced together to make the correct filenames:
What I am looking for (and know exists as I have seen it in a long lost thread) is a modifier to put infront of my token number so that I can start counting tokens from the end of the filename instead of the beginning to allow me to sucessfully pick out the correct extension every time. I also want to know this as it would be very useful in my other codes. (I am aware there are better methods of modifying simple filenames such as these but I really want to know what this modifier is so as I can extract the extensions for file metadata later down the line.
for /F "tokens=1 delim................................. Counts from begginning
for /F "tokens=<HERE>1 delim....................Counts from end
Here is the shabby code in question:
:: Set Filename
for /F "tokens=*" %%j in ('dir /b *x*.dxf') do (set Filename=%%j)&(set endy=1)
:: Isolates the Part Number & Revision & assigns them to var's %%N & %%R respectively
for /F "tokens=1 delims=x." %%N in ("!Filename!") DO (set Number=%%N)
for /F "tokens=2 delims=x." %%R in ("!Filename!") DO (set Revision=%%R)
rename "!Filename!" "!Number!_!Revision!.dxf"
if "%endy%" EQU "0" (GOTO:eof)
I anyone can help I'd be increadibly gratefull as I've sifted through google for hours!