Macos 我怎样做一个“a”字;“文件存在”;自动机应用程序中的Shell

Macos 我怎样做一个“a”字;“文件存在”;自动机应用程序中的Shell,macos,shell,operating-system,command,automator,Macos,Shell,Operating System,Command,Automator,我正在Mac Automator中制作一个小型Automator应用程序,我想做的是: 如果ModLoader.class存在,请继续执行Automator工作流 如果ModLoader.class不存在,请将ModLoader.class从其他文件路径复制并粘贴到其他文件路径 有人能帮忙吗?您能添加一个shell脚本或AppleScript操作吗 f1="/path/to/ModLoaderClass.class" f2="/path2/to/ModLoaderClass.class"

我正在Mac Automator中制作一个小型Automator应用程序,我想做的是:

  • 如果ModLoader.class存在,请继续执行Automator工作流

  • 如果ModLoader.class不存在,请将ModLoader.class从其他文件路径复制并粘贴到其他文件路径


有人能帮忙吗?

您能添加一个shell脚本或AppleScript操作吗

f1="/path/to/ModLoaderClass.class"
f2="/path2/to/ModLoaderClass.class"

if [ ! -f "$f2" ]; then
    cp "$f1" "$f2"
fi
cp
还有一个
-n
选项,使其不会覆盖现有文件:
cp-n/path/to/ModLoaderClass.class/path2/to/ModLoaderClass.class