Probably a newbie question: Same folder actions on duplicated folders?

Hi

I have some folders with folder actions on them. If I copy those folders (manually), I want the same folder actions on those new folders. But the actions don’t seem to be copied with them automatically. Is there a way? I seem to have to apply them each time I copy the specific folders, can’t be the way to go…

It’s basically a script that sets a label if a folder isn’t empty. If there are other ways to do is, also good. I’m very new to Applescript, the syntax is no problem but I lack some knowledge in to what’s possible and not.

Thanks!

Nobody? I searched all over the net, and I keep finding ways to copy folders with applescript, but none of the info tell me if it’s possible to copy applescript by duplicating a folder…

This can’t be that farfetched, no?

Hi,

attached folder actions are not copied automatically with the Finder.
Get the folder action parameters of the source folder with System Events and assign them to the destination folder

Thanks for the reply Stefan,

So I can write a script that says something like:


on duplicating folder

tell finder
System event that copies folder actions
end tell

end on duplicating folder

If someone could give me a push by giving the correct syntax to register a duplicating process, then I’m off to trying it out!

you need something like this


set sourceFolder to choose folder
set destinationFolder to choose folder
set actionScript to missing value
tell application "System Events"
	repeat with anAction in (get folder actions)
		if path of anAction is sourceFolder then
			set actionScript to path of script 1 of anAction
			exit repeat
		end if
	end repeat
end tell

tell application "Finder" to duplicate sourceFolder to destinationFolder
if actionScript is not missing value then
	tell application "System Events"
		attach action to destinationFolder using actionScript
	end tell
end if