Here is the native Windows CMD method for this (no vb / java script).
If you want to be very fast and simple, just use this in the CMD window instead of writing a batch in general:
FOR /R "Drive:\folder\subfolder\" %Z IN (*.tiff) DO @( FOR /F "Tokens=1-6 delims=:-\/. " %A IN ("%~tZ") DO @( ren "%~dpnxZ" "%~C%~A%~B%~D%~E%~F%~nZ%~xZ") )
If you still prefer a batch / CMD file, this is overwriting your script to work as a CMD and overwriting all the files in the directory matching the specific search pattern, which is in the format "YYYYMMDDHHM [Name] [extention]"
@( SETLOCAL echo off SET "_Skip=NO" Set "_elvl=0" ) IF /I "%~2" EQU "" ( SET "_Skip=YES" ) IF /I "%~1" EQU "/?" ( SET "_Skip=YES" ) IF /I "%~1" EQU "?" ( SET "_Skip=YES" ) IF /I "%_Skip%" EQU "YES" ( ECHO. Usage: ECHO. ECHO. Rename.bat "Drive:\Path\" "File Glob to match" ECHO. ECHO. Example: ECHO. ECHO. Rename.bat "C:\Users\%Username%\Desktop\" "*.lnk" ECHO. Set "_elvl=2" GOTO :Finish ) ECHO. Searching through "%~1" for Files matching this pattern: "%~2" ECHO. FOR /R "%~1" %%Z IN (%~2) DO ( FOR /F "Tokens=1-6 delims=:-\/. " %%A IN ("%%~tZ") DO ( REN "%%~dpnxZ" "%%~C%%~A%%~B%%~D%%~E%%~F%%~nZ%%~xZ) ) ECHO. ECHO. Completed rename of all files matching pattern "%~2" which were found within path: "%~1" ECHO. :Finish ( EndLocal EXIT /B %_elvl% )
source share