Hi
I need to batch rename a bunch of files that are located in one directory and have a name like this: "GF6DA7BXG44DO7BRGU4DQNJZG44DKNRRG42HYSKNI5PTEMBSGAYDIMRYL4ZDAMRTGIZXYLTKOBTXY2LNMFTWKL3KOBSWO7DOOVWGY"
to 0001.jpg and so on till all processed.
Would you please post here the batch file code?
Thank you very much
Batch rename
Moderator: DosItHelp
Re: Batch rename
This is trivial with JREN.BAT - a hybrid JScript/batch regular expression renaming utility
It is not much more complicated to use pure batch
Dave Benham
Code: Select all
call jren "^.*" "lpad($n,'0000')+'.jpg'" /j /p "c:\pathToYourFolder" /rfm "^[a-z0-9]+$"
Code: Select all
@echo off
setlocal enableDelayedExpansion
pushd "c:\pathToYourFolder"
for /f "delims=: tokens=1*" %%A in (
'"dir /b /a-d | findstr /x [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]* | findstr /n ."'
) do (
set "name=0000%%A"
echo "%%B" --^> "!name:~-4!.jpg"
ren "%%B" "!name:~-4!.jpg"
)
popd
Dave Benham
Re: Batch rename
I originally forgot to left zero pad the number to 4 digits. I edited my prior post to add the padding