I have some file such as
CCC_a003.jpg in Windows 7
and I'm trying to use batch to rename these file to
Just to swap the content between
I have been searching for a while, but still don't know how to do this. Can anyone help? Thanks.
This question is tagged with
~ Asked on 2012-12-23 17:42:31
@echo off pushd "pathToYourFolder" || exit /b for /f "eol=: delims=" %%F in ('dir /b /a-d *_*.jpg') do ( for /f "tokens=1* eol=_ delims=_" %%A in ("%%~nF") do ren "%%F" "%%~nB_%%A%%~xF" ) popd
Note: The name is split at the first occurrence of
_. If a file is named "part1_part2_part3.jpg", then it will be renamed to "part2_part3_part1.jpg"
~ Answered on 2012-12-23 18:49:31
Ren is for
ren ( where the file is located ) ( the new name )
ren C:\Users\&username%\Desktop\aaa.txt bbb.txt
it will change aaa.txt to bbb.txt
Your code will be :
ren (file located)AAA_a001.jpg a001.AAA.jpg ren (file located)BBB_a002.jpg a002.BBB.jpg ren (file located)CCC_a003.jpg a003.CCC.jpg
and so on
IT WILL NOT WORK IF THERE IS SPACES!
Hope it helps :D
~ Answered on 2012-12-23 17:57:12