我正在尝试编写一个AppleScript来从剪贴板中提取字符串,解析它并在满足条件时创建一个文件夹。
字符串的格式始终为" yyyymmdd.hhmmss.abc.xyz"
代码粘贴在下面:
set datevar to item 1 of my Splitstring(the clipboard, ".")
set yearvar to (datevar / 10000) as integer
on Splitstring(stringvar, del)
set defaultdel to AppleScript's text item delimiters
set AppleScript's text item delimiters to del
set arrayvar to every text item of the stringvar
set AppleScript's text item delimiters to defaultdel
return arrayvar
end Splitstring
.
.
.
.
.
.
if yearvar < 2002 then
set tempvar to "/Volumes/My Passport/Cygnus-CME/Cycle-22-Min/Slow_CME/"
set loc to POSIX path of tempvar
tell application "Finder"
make new folder at loc with properties {name:datevar} # ---- Error location
end tell
end if
如果路径是其他内容,则创建新文件夹的命令可以正常工作。我已经确认已安装外置高清,并且我的帐户的权限为r&amp; w。
我做错了什么?我设置外置HD路径的方式有问题吗?
感谢您的帮助!
答案 0 :(得分:0)
Finder期望HFS路径(冒号分隔)。 HFS路径始终使用磁盘名称启动,而不是Volumes
set loc to "My Passport:Cygnus-CME:Cycle-22-Min:Slow_CME:"
tell application "Finder"
make new folder at folder loc with properties {name:datevar}
end tell
或
set loc to POSIX file of tempvar
tell application "Finder"
make new folder at loc with properties {name:datevar}
end tell