AppleScript 通过右键单击复制并粘贴文件

发布于 2024-11-30 23:27:33 字数 543 浏览 0 评论 0原文

抱歉,我没有更多的基础,但我对 AppleScript 一无所知。基本上我想右键单击一个文件或文件夹并运行一个脚本,将其复制到具有恒定目录结构的新位置。显然,脚本编写已经很糟糕了,但是像这样的..

path = /Volumes/RENDERS/ThisShow/ThisShot/ThisShow_ThisShot_v10/

newPath = from 'path' ReplaceText("/Volumes/RENDERS/" , "/Volumes/Raid-Renders /")

告诉应用程序“Finder”将文件“path”复制到“newPath”并替换

在此示例中,“path”将是正确的文件或文件夹启动脚本时单击。本示例中的新文件夹为“/Volumes/Raid-Renders/ThisShow/ThisShot/ThisShow_ThisShot_v10/”。所以想法是它将“ThisShow_ThisShot_v10”文件夹及其内容复制到“/Volumes/Raid-Renders/ThisShow/ThisShot/”

感谢您的帮助。我知道这里没什么可做的。

Sorry I don't have more of a foundation but I know nothing of AppleScript. Basically I want to right-click on a file or folder and run a script that will copy it to a new location with a constant directory structure. So obviously the scripting is way off, but something like this..

path = /Volumes/RENDERS/ThisShow/ThisShot/ThisShow_ThisShot_v10/

newPath = from 'path' ReplaceText("/Volumes/RENDERS/" , "/Volumes/Raid-Renders/")

tell application "Finder" to duplicate file 'path' to 'newPath' with replacing

In this example "path" would be the file or folder that was right clicked on when launching the script. The new folder in this example would be "/Volumes/Raid-Renders/ThisShow/ThisShot/ThisShow_ThisShot_v10/". So the idea is that it would copy "ThisShow_ThisShot_v10" folder and its content to "/Volumes/Raid-Renders/ThisShow/ThisShot/"

Thanks for any help. I know there isn't a lot to go on here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三月梨花 2024-12-07 23:27:33

这应该可以做到:

set thisFolder to the POSIX path of (choose file)
set the destinationFolder to (replaceText(thisFolder) as POSIX file as alias)
tell application "Finder" to duplicate (thisFolder as POSIX file as alias) to the destinationFolder with replacing

on replaceText(this_folder)
    set AppleScript's text item delimiters to "RENDERS"
    set these_items to every text item of this_folder
    set AppleScript's text item delimiters to "Raid-Renders"
    return these_items as string
end replaceText

据我所知,您不能将 AppleScript 分配给右键单击菜单。但是,您可以创建菜单栏脚本。为此,请首先将此脚本另存为本地 Library 文件夹的 Scripts 文件夹中的常规脚本文件。

如果您的主菜单栏中(位于屏幕顶部)有一个看起来像卷轴的小图标(以前称为脚本菜单),则脚本应该出现在该菜单中的某个位置。如果您没有看到该图标,请运行 AppleScript Utility(位于 /Applications/AppleScript/AppleScript Utility)并选中在菜单栏中显示脚本菜单< /代码> 复选框。

现在,运行脚本所需要做的就是打开脚本菜单,找到您的脚本,然后单击它一次。问题?问。 :)

This should do it:

set thisFolder to the POSIX path of (choose file)
set the destinationFolder to (replaceText(thisFolder) as POSIX file as alias)
tell application "Finder" to duplicate (thisFolder as POSIX file as alias) to the destinationFolder with replacing

on replaceText(this_folder)
    set AppleScript's text item delimiters to "RENDERS"
    set these_items to every text item of this_folder
    set AppleScript's text item delimiters to "Raid-Renders"
    return these_items as string
end replaceText

As far as I know, you can't assign an AppleScript to a right-click menu. However, you can create a menu bar script. To do this, first save this script as a regular script file in the Scripts folder of the local Library folder.

If you have a little icon in your main menubar (located at the top of the screen) that looks like a scroll (formerly known as the Script Menu), the script should appear somewhere in that menu. If you don't see the icon, run AppleScript Utility (located at /Applications/AppleScript/AppleScript Utility) and check the Show Script Menu in menu bar checkbox.

Now, all you have to do to run the script is open up the Script Menu, find your script, and just click on it once. Questions? Ask. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文