I have a folder struktur like this:
/1/1/master.jpg
/1/2/master.jpg
/1/3/master.jpg
/2/1/master.jpg
/2/2/master.jpg
/2/3/master.jpg
...
@echo off
setlocal EnableDelayedExpansion
cd C:\Parent\Folder\OfFirstNumberedFolders
for /F "delims=" %%a in ('dir /B /S /A-D master.jpg') do (
set "fullName=%%a"
for /F "tokens=1-3 delims=\" %%b in ("!fullName:%CD%=!") do (
ECHO ren "%%a" "%%b_%%c_%%d"
)
)
Try this in Windows. Remove the echo
to make it actually perform the rename.
@echo off
for /f "delims=" %%z in ('dir "master.jpg" /b /s /a-d ') do (
for %%a in ("%%~dpz%\.") do (
for %%b in ("%%~dpa\.") do (
echo ren "%%z" "%%~nxb_%%~nxa_%%~nxz"
)
)
)
pause