更新时间:2023-08-25 20:02:40
在AutoHotKey中,您将使用以下内容:
In AutoHotKey you'd use something like this:
; set the value
String := "Hamburger.Hill.1987.BluRay.720p.x264.mov"
; capture the extension
RegexMatch(String, "(.*)(\.[^.]*?$)", SubPart)
Filename := SubPart1
Extension := SubPart2
; replace all the dots with spaces
Output1 := RegexReplace(Filename, "\.", " ")
; remove the unwanted characters after the year
Output2 := RegexReplace(Output1, "(?<=\d{4}).*", "")
strMessage := ""
, strMessage .= "String = '" . String . "'
, strMessage .= "`nOutput1 = '" . Output1 . Extension "'
, strMessage .= "`nOutput2 = '" . Output2 . Extension "'
MsgBox, % strMessage
样本输出
String = 'Hamburger.Hill.1987.BluRay.720p.x264.mov'
Output1 = 'Hamburger Hill 1987 BluRay 720p x264.mov'
Output2 = 'Hamburger Hill 1987.mov'
#.:: ; Replace all "." (except before extension) with spaces
OldCLip := ClipboardAll
Clipboard=
Send ^c
ClipWait
; MsgBox % Clipboard ; for testing
; set the value
String := Clipboard
; String := "Hamburger.Hill.1987.BluRay.720p.x264.mov"
; capture the extension
RegexMatch(String, "(.*)(\.[^.]*?$)", SubPart)
Filename := SubPart1
Extension := SubPart2
; replace all the dots with spaces
Output1 := RegexReplace(Filename, "\.", " ")
; remove the unwanted characters after the year
Output2 := RegexReplace(Output1, "(?<=\d{4}).*", "")
; strMessage := ""
; , strMessage .= "String = '" . String . "'
; , strMessage .= "`nOutput1 = '" . Output1 . Extension "'
; , strMessage .= "`nOutput2 = '" . Output2 . Extension "'
; MsgBox, % strMessage
if ( String ) {
strMessage := "Renaming '" . Output1 . Extension . "' to '" . Output2 . Extension . "'"
MsgBox, % strMessage
FileMove, % Output1 . Extension, % Output2 . Extension
} ; end if
Clipboard := OldClip
return