with the batch file below, I numerically rename all the .mp4 files in the folders, incremented by 1, but it doesn't rename them as I would like.
@Set "count=0"
@For /F "Delims=" %%I In ('Dir /B/S/A-D-S "*.mp4" 2^>NUL')Do @(
For %%J In ("%%~pI.")Do @(Set /A count+=1
SetLocal EnableDelayedExpansion
Ren "%%I" "!count!%%~xI"
EndLocal))
@Pause
Now the rename is like this:
Folder1 (60 files in it)
Folder2 (60 files in it)
Folder3 (30 files in it)
But I would like to be
Folder1 (60 files in it)
Folder2 (60 files in it)
Folder2 (30 files in it)
Folder2 (45 files in it)
Each sub-folder should start renaming from 1 and end at how many files are in the folder.
Can someone help me in this direction?
I would assume that the following modification would suit your needs:
@For /F "Delims=" %%G In ('Dir /A:D-S /B /S 2^>NUL') Do @(
Set "Count=0"
For /F "Delims=" %%H In (
'Set "PathExt=" ^& %SystemRoot%\System32\where.exe "%%G":"*.mp4" 2^>NUL'
) Do @(
Set /A Count += 1
SetLocal EnableDelayedExpansion
Ren "%%H" "!Count!%%~xH"
EndLocal
)
)
@Pause