如何在Automator Shell脚本中使用空格的路径?
我有一个Automator工作流程,该工作流程应将所选文件的创建日期设置为我要输入的日期。不幸的是,我的道路有空间。因此,它不起作用。 我尝试了几种变体,例如:
SetFile -d \"$1 12:00:00\" "$@2"
SetFile -d \"$1 12:00:00\" \"$@2\"
SetFile -d \"$1 12:00:00\" '$@2'
SetFile -d \"$1 12:00:00\" \'$@2\'
这条路就像以下内容: /users/simon/documents/steuern/steuern 2021/scan_000775.pdf
我使用的外壳是ZSH,安装了OH-MY-ZSH。
这是我拥有的工作流程:
- 询问finder -object
- get guet of variable
- 询问文本输入
- 集值的变量
- 询问可变
- execute shell脚本的值:“ setFile -d” $ 1 12:00:00:$ 1 12:00:00“ $@2” “
任何人都可以告诉我如何编写ShellScript以将路径名与空格使用? 那会很好。谢谢。
I have an Automator workflow which should set the CreationDate of the selected file to a date which I want to enter. Unfortunately my path have spaces. Therefore it doesn'w work.
I've tried several variants like:
SetFile -d \"$1 12:00:00\" "$@2"
SetFile -d \"$1 12:00:00\" \"$@2\"
SetFile -d \"$1 12:00:00\" '$@2'
SetFile -d \"$1 12:00:00\" \'$@2\'
The path is like follows:
/Users/simon/Documents/Steuern/Steuern 2021/Scan_000775.pdf
The shell I use is ZSH with oh-my-zsh installed.
This is the Workflow I have:
- Ask for Finder-Object
- Get value of variable
- Ask for Text input
- Set value of variable
- Ask for value of variable
- execute shell script: "SetFile -d "$1 12:00:00" "$@2""
Can anyone tell me how to write the shellscript to use pathnames with spaces?
That would be very nice. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您想要:
解释:逃脱的引号会阻止它们像引号一样行动(它将它们变成了正常的字符);在这种情况下,您希望它们充当报价,因此您不应该逃脱它们。另外,
“ $@2”
没有从$ 2
开始获得参数,它得到了参数的全部,并粘贴一个“ 2 “到最后一个。如果您需要除第一个的所有参数,请使用“ $ {@:2}”
而不是。If I'm understanding right, you want:
Explanation: escaping quotes prevents them from acting like quotes (it turns them into normal characters); in this case, you want them to function as quotes, so you shouldn't escape them. Also,
"$@2"
doesn't get the arguments starting at$2
, it gets all of the arguments, and sticks a "2" to the end of the last one. If you want all the arguments except the first, use"${@:2}"
instead.