Hi all,
I’m trying to figure out the easiest way to create an applescript that can be run periodically as an application to do some maintenance with folders. For example:
there’s 2 folders on the desktop. one is named “George Project” and the other named “Rocco project”. I need any folders, and their respective sub-folders, containing George, to be moved to a george folder on a network drive (/Volumes/AMT/George), and the same thing with any folders containing Rocco, etc. All of these named folders would only be in 2 locations, so I’d like the script to check both locations for any folders containing these names and move them to the right place on the network.
Right now, I have the script below…is there an easier way to write the file paths as I’ve shown above? and is there a way to make theWatchedFolder and target_path as written in this script check multiple folders for multiple names and move files/folders respectively as shown above?
set theWatchedFolder to ((path to home folder) as text) & "source:" as alias
set target_path to ((path to home folder) as text) & "destination:" as alias
global theDetectedItems
set theDetectedItems to {}
tell application "Finder"
set theDetectedItems to (every item of theWatchedFolder whose name contains "rocco") as alias list
try
repeat with aDetectedItem in theDetectedItems
-- duplicate aDetectedItem to (target_path with replacing and exact copy
move aDetectedItem to (target_path) with replacing
end repeat
on error errmsg number errnbr
display dialog "[ " & errnbr & " ] " & errmsg
end try
end tell
Thanks so much for any help, it is greatly appreciated
Rocco