Rookerin
asked on
Batch REN, removing a word from a file with 2 .dots.
Alright, so here's my deal. I'm not the most profficent with DOS batch commands, but I'm trying to create a scheduled task to handle removing a word from all files in a specific folder daily.
The folder contains files named like this:
ABC0.75gy_white.jpg
DEF1.23AB_white.jpg
I want to remove the _white from all filenames, no matter where it is.
The examples I've found, described below, break when there are two dots in the statement, breaking the delims, I believe.
For what it's worth, the _white word should always be right before the jpg, so if there was a way to remove "_white.jpg" and tack on .jpg, that would work as a solution.
Thanks!
The folder contains files named like this:
ABC0.75gy_white.jpg
DEF1.23AB_white.jpg
I want to remove the _white from all filenames, no matter where it is.
The examples I've found, described below, break when there are two dots in the statement, breaking the delims, I believe.
For what it's worth, the _white word should always be right before the jpg, so if there was a way to remove "_white.jpg" and tack on .jpg, that would work as a solution.
Thanks!
@echo off&for %%f in (*_white*) do call :ProcessFile %%f
goto :eof
:ProcessFile
echo %1
for /F "delims=_. tokens=1,3" %%c in ("%1") do ren "%1" "%%c.%%d"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.