
使用 AutoHotkey,嘗試循環遍歷絕對路徑中的所有 jpg 並將所有空白替換為 _ 。我已經為此奮鬥了很多年,只做到了這一點:
#!l::
Loop, C:\Users\me\Desktop\OM\renaming folder\*V1.jp*
StringReplace, NewStr, OldStr, %A_SPACE%, +, All
;; StringReplace, A_LoopFileName, %A_LoopFileName%, %A_SPACE%, +, All ; also tried this, then I get an error about an illegal char in var name
Return
答案1
filePath := "C:\Path\To\Images"
Loop, %filePath%\*V1.jp*
{
newName := RegExReplace(A_LoopFileName, "\s", "_")
FileMove, %A_LoopFileFullPath%, %filePath%\%newName%
MsgBox % "New filename: " newName
}
這應該可以解決問題。只需確保首先在測試批次上執行此命令,這樣您就不會意外地將所有映像重命名為您不想要的名稱。
如果您不想重新命名圖像,只需刪除FileMove, %A_LoopFileFullPath%, %filePath%\%newName%
.
答案2
AutoHotkey 是不適合這項工作的工具,因為您在 Windows 上有一些很棒的程序,例如 Advanced Renamerhttp://www.advancedrenamer.com/
如果您使用的是 Linux,那麼使用 Perl Rename(重新命名)就更容易了。
兩者都使用標準正規表示式。