开发者

AppleScript copy and paste file with right-click

开发者 https://www.devze.com 2023-03-30 10:39 出处:网络
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 dir

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.


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. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号