以下文件中的所有文件夾是我的嘗試:集FOLDERNAME =文件夾名稱:! =批量重命名含有特定模式
@echo off
REM Prefix zz_ to folders containing episodes with zz_
setlocal enabledelayedexpansion enableextensions
for /r "G:\itunes\Podcasts\" %%f in (zz_*.mp3) do (
set N=%%~pf~
set N=!N:\itunes\Podcasts\=!
set N=!N:\=!
if exist %%f ren "g:%%~pf" "zz_!N!"
)
pause
但我收到錯誤消息:該進程無法訪問,因爲它的文件正在被另一個進程使用。 我不是一個程序員,只是削減&粘kinda傢伙,所以謝謝你的任何幫助。
所以,上面的錯誤當然是我試圖緩衝目錄(g:\ itunes \ podcasts)時修改子目錄。所以以下笨重的代碼確實有效,但有一個例外。
@echo off
setlocal enabledelayedexpansion enableextensions
REM Prefix zz_ to folders containing episodes with zz_
for /r "G:\itunes\Podcasts\" %%f in (zz_*.mp3) do (
set foldername=%%~pf
set foldername=!foldername:~17!
set foldername=!foldername:\=!
if exist %%f echo if exist %%f ren "g:%%~pf" "zz_!foldername!" >>g:\trash.bat
)
call g:\trash.bat
del g:\trash.bat
pause
它不處理包含感嘆號的文件名。有什麼想法嗎?
是否正在使用.mp3文件?因爲那就是那個錯誤信息所暗示的。 – SomethingDark
關閉'echo off',看看你正在做的奇怪的事情。 –