【发布时间】:2019-11-24 11:56:56
【问题描述】:
我有一个 AppleScript 以别名形式处理路径并将它们转换为 posix。
这些路径将在此自动化工作流程的第二步中由 shell 脚本处理。
问题是路径包含空格。
我不知道如何处理,所以我有这个子程序来删除任何空格并将其替换为\。
on replaceChars(this_text, search_string, replacement_string)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to saveTID
return this_text
end replaceChars
关于 Applescript 我做的部分
-- convert the path from the alias form to posix
set fileInputPosix to (the POSIX path of thePath)
-- replace " " with "\ "
set quotedForm to replaceChars(fileInputPosix, space, "\\ ")
此时路径似乎没问题,类似于
'/Users/myUser/Desktop/my\ video\ file.png'
但是当我将此路径传递给 shell 脚本时,它不会接受。
【问题讨论】:
标签: bash applescript automator