问题描述
我正在寻找一个简单的AutoHotkey代码以转换点."文件名到空间的示例示例Hamburger.Hill.1987.BluRay.720p.x264
需要转换为Hamburger Hill 1987 BluRay 720p x264
.
I am looking for a simple AutoHotkey Code to convert dot "." of file name to space Example Hamburger.Hill.1987.BluRay.720p.x264
needs to be converted to Hamburger Hill 1987 BluRay 720p x264
.
以字符串开头:Hamburger.Hill.1987.BluRay.720p.x264.mov
结果字符串:Hamburger Hill 1987 BluRay 720p x264.mov
请注意扩展名之前的点应保留.
Note the dot before the extension should be retained.
然后在单独的操作中,删除4位数字后的字符串.此操作还应该删除文件扩展名.
Then in a separate operation, remove the string of characters following the 4 digit year. This operation should also remove the file extension.
以字符串开头:Hamburger Hill 1987 BluRay 720p x264.mov
结果字符串:Hamburger Hill 1987.mov
这是我的代码
#.:: ; Replace all "." (except before extension) with spaces
OldCLip := ClipboardAll
Clipboard := ""
Send ^c
ClipWait, .2
; MsgBox % Clipboard ; for testing
if Clipboard FileMove, % Clipboard, % RegExReplace(Clipboard, "\.(?=.*?\.[^.]+$)", " ")
Clipboard := OldClip
return
我仔细查看,但看不到与此相关的代码.在此先感谢您的帮助.
I looked throughly but could not see code related to this. Thanks in advance for your help.
推荐答案
在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
这篇关于自动热键转换点“."太空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!