使用下面的批處理檔案,我以數字方式重命名檔案夾中的所有 .mp4 檔案,增量為 1,但它并沒有按照我的意愿重命名它們。
@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
現在重命名是這樣的:
檔案夾 1(其中 60 個檔案)
- 1.mp4、2.mp4....60.mp4
檔案夾 2(其中 60 個檔案)
- 61.mp4, 62.mp4....120.mp4
檔案夾 3(其中 30 個檔案)
- 121.mp4, 122.mp4....160.mp4
但我想成為
檔案夾 1(其中 60 個檔案)
- 1.mp4、2.mp4....60.mp4
檔案夾 2(其中 60 個檔案)
- 1.mp4、2.mp4....60.mp4
檔案夾 2(其中 30 個檔案)
- 1.mp4、2.mp4....30.mp4
檔案夾 2(其中 45 個檔案)
- 1.mp4, 2.mp4....45.mp4
每個子檔案夾應該從 1 開始重命名,并以檔案夾中有多少檔案結束。
有人可以在這個方向上幫助我嗎?
uj5u.com熱心網友回復:
我認為以下修改將適合您的需求:
@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
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/507893.html
上一篇:Batch中^<字符的組合
