I receive useless DOS file names from outside systems. I need to parse the file name into variables and then rename the file with a usefule name.
EXAMPLE: useless filename 982537.a.null.1.a.tif
DESIRE TO RENAME: usable filename 982537.1.a.tif
ASSUME (but cannot remember how) I can parse into a.b.c.d.e.f into a variable then rename into a.d.e.f form
Thanks !
Glad to find this forum - DOS still kicks buttocks !
Hello - new to forum - want to parse file name to variables
Moderator: DosItHelp
Re: Hello - new to forum - want to parse file name to variab
try this
Code: Select all
set "filename=982537.a.null.1.a.tif"
for /f "tokens=1-6delims=." %%a in ("%filename%") do rename "%%a.%%b.%%c.%%d.%%e.%%f" "%%a.%%d.%%e.%%f"
Re: Hello - new to forum - want to parse file name to variab

I appreciate your help !
Re: Hello - new to forum - want to parse file name to variab
you can simply add an additional for loop:
Code: Select all
cd /d "x:\my picture folder"
for /f "delims=" %%i in ('dir /a-d /b *.tif') do for /f "tokens=1-6delims=." %%a in ("%%~nxi") do rename "%%a.%%b.%%c.%%d.%%e.%%f" "%%a.%%d.%%e.%%f"