Attach folder action to a sub folder

Hi!

I have some problem adding a folder action to a sub folder from a duplicated folder.
My orginal folder that will be duplicated, named “Projekt” contains a sub folder named “Export”.

The script asks me what the new name of duplicated folder will be and I will always add an action to the sub folder “Export”.

I have tried that you see below but i can’t get it to work, that is the last part that doesn’t work.
Adding folder action to sub folder Export.

Thankful for help.

Jonne

set folderToDuplicate to alias “Macintosh HD:Users:jonneeckenberger:pictures:Projekt”
repeat
set newName to text returned of (display dialog “Nytt Projektnamn” default answer “” buttons {“Cancel”, “OK”} default button 2)
if the newName contains “:” then
beep
display dialog “Använd inte kolon i namnet(:).” buttons {“Cancel”, “OK”} default button 2
else if the newName contains “/” then
beep
display dialog “Använd inte snedstreck i namnet (/).” buttons {“Cancel”, “OK”} default button 2
else
exit repeat
end if
end repeat

tell application “Finder”
set newFolder to duplicate folderToDuplicate
set name of newFolder to newName

[b]tell application “System Events” to attach action to alias " Macintosh HD:jonneeckenberger:Pictures:newName:Export" using alias
“Macintosh HD:Library:Scripts:Folder Action Scripts:Duplicate.scpt”

end tell[/b]

Hi,

First of all remove the space character at the beginning of the path to the export folder.
The dictionary of System events says about the classes of the parameters

function syntax
set theResult to attach action to folder ¬
using unicode text

that means, don’t use alias but folder and a Unicode text path

tell application "System Events" to attach action to folder "Macintosh HD:jonneeckenberger:Pictures:newName:Export:" using 
	"Macintosh HD:Library:Scripts:Folder Action Scripts:Duplicate.scpt"