我有一个AppleScript处理别名表单中的路径,并将它们转换为posix。
这些路径将由此automator工作流的第二步中的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脚本时,它不会接受该路径。
https://stackoverflow.com/questions/57045531
复制相似问题