Reputation: 105
I have these filenames and I want to replace this text SYPTE1-PC to SHEFFIELD and in this format.
PRESENT FORMAT
1UYK08HJ_20140403165858071_SYPTE1-PC.jpg ,
1YK0BHJX_20140403165902791_SYPTE1-PC.jpg
REQUIRED FORMAT
1UYK08HJ_SHEFFIELD_2014_04_03_16:58:58:071.jpg
1YK0BHJX__SHEFFIELD_2014_04_03_16:59:02:791.JPG`
this is my query
@echo off
pushd "C:\Users\IT-Administrator\Desktop\export" || exit /b
for /f "tokens=1-4 delims=_." %%A in ('dir /b /a-d *_*.jpg') do (
Echo ren %%A_%%B_%%C.%%D %%A_%%C_%%B.%%D
)
popd
I am able to change the format but cannot replace text and datetime with colons.
Upvotes: 0
Views: 57
Reputation: 41224
This will create renfiles.bat.txt
for you to examine and rename to .bat
and execute if you are happy with it.
It uses a helper batch file called repl.bat
- download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
Place repl.bat
in the same folder as the batch file or in a folder that is on the path.
@echo off
dir *.jpg /b /a-d |find /i /v "%~nx0" |find /i /v "repl.bat" |repl "(.*?_)(....)(..)(..)(..)(..)(..)(...).*(\..*)" "ren \q$&\q \q$1SHEFFIELD_$2_$3_$4-$5_$6_$7_$8$9\q" xa >"renfiles.bat.txt"
Upvotes: 1