首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Automator -处理将从Applescript传递到Shell脚本的路径上的空格

Automator -处理将从Applescript传递到Shell脚本的路径上的空格
EN

Stack Overflow用户
提问于 2019-07-16 02:45:30
回答 2查看 629关注 0票数 0

我有一个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脚本时,它不会接受该路径。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57045531

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档