Hey I’m just now learning the ropes and right now I really need a script to move a folder based on its name.
I need a script that moves a folder as its added with the word accent in it to my user’s documents folder. My u/n is John.
How would I do this so that it will work automatically? I know how to attach the scripts, I’m just trying to figure out the coding. Any help would be very much appreciated.
You might want to start with the Applescript folder on your Hardrive. Check out the folder “Example Scripts”. Maybe even do a search on these forums for something like “move + folder”
This may help - save it as a script and attach it to the watched folder. You can set multiple target folders and then use if-then-else statements to move them around
property targetfolder : alias "pathto:Users:myuserfolder:Documents:"
on adding folder items to this_folder after receiving added_items
repeat with thisFile in added_items
tell application "Finder"
set fileName to name of thisFile
if fileName contains "accent" then
move thisFile to targetfolder
end if
end tell
end repeat
end adding folder items to
Dude… I’d have to say moving folders is a discussed topic…
This worked for me. Tried attaching it as a folder action to my desktop folder and new folders were moved as soon as created.
on adding folder items to ThisFolder
set WhatEverYourSearchingFor to "accent"
set DocsFolder to path to "docs" from user domain
tell application "Finder" to move ((every folder whose name contains WhatEverYourSearchingFor) in ThisFolder) to DocsFolder
end adding folder items to
Won’t allow me to save on account of: “File pathto:Users:myuserfolder:Documents: wasn’t found.”
You’ll have to set your own file path first - just use “choose folder” from Script Editor, select your target folder and copy the path from the Result window. Then you’ll be able to compile it and save it…
"
on adding folder items to ThisFolder
set WhatEverYourSearchingFor to “accent”
set DocsFolder to path to “docs” from user domain
tell application “Finder” to move ((every folder whose name contains WhatEverYourSearchingFor) in ThisFolder) to DocsFolder
end adding folder items to
"
This works, its good, but when files with duplicate names come in, it doesnt move them.
Is there any way to edit the name, or set it to overwrite duplicates?
on adding folder items to ThisFolder
set WhatEverYourSearchingFor to "accent"
set DocsFolder to path to "docs" from user domain
tell application "Finder" to move ((every folder whose name contains WhatEverYourSearchingFor) in ThisFolder) to DocsFolder with replacing
end adding folder items to