在Automator中使用“运行Shell脚本”时无法定义变量

时间:2018-11-28 21:31:24

标签: macos shell automator

此刻,我正在Automator中运行以下脚本,它运行得很好:

def goal_diff(matches):
    return matches['home_team_goal'] - matches['away_team_goal']
match_all['home_away_goal_diff'] = goal_diff(match_all)

尽管如此,我打算在引入一些变量的同时使其变得更整洁,例如:

match_all['home_away_goal_diff'] = match_all['home_team_goal'] - match_all['away_team_goal']

但是当我运行它时,什么也没发生。我在这个论坛上发现了很多类似的问题,主要的解决方案是删除#Copy Originals to SS1 on the main Server find /Volumes/styleshoot/TJXE-HHPS-SS01/ -type f -exec cp -p {} "/Volumes/Hams Hall Workspace/StyleShoot1_WIP" \; #Make Directory for Styleshoot 1 Backups mkdir -p /Volumes/Hams\ Hall\ Workspace/SS\ Backup/$(date +%Y%m%d)/SS1 #Copy SS1 for into Backup folder find /Volumes/styleshoot/TJXE-HHPS-SS01/ -type f -exec mv {} /Volumes/Hams\ Hall\ Workspace/SS\ Backup/$(date +%Y%m%d)/SS1 \; 周围的空格。尽管这对输出没有影响。任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

如果有人要谷歌搜索,问题出在我尝试定义mkdir位置时。不需要""双引号。

更改此:

Backup="/Volumes/Hams\ Hall\ Workspace/SS\ Backup/$(date +%Y%m%d)/SS1"

为此:

Backup=/Volumes/Hams\ Hall\ Workspace/SS\ Backup/$(date +%Y%m%d)/SS1 

最终脚本如下,并根据需要运行:

Original="/Volumes/styleshoot/TJXE-HHPS-SS01/"
Backup=/Volumes/Hams\ Hall\ Workspace/SS\ Backup/$(date +%Y%m%d)/SS1
MainServer="/Volumes/Hams Hall Workspace/StyleShoot1_WIP"

mkdir -p "$Backup"

find "$Original" -type f -exec cp -p {} "$MainServer" \;
find "$Original" -type f -exec mv {} "$Backup" \;