Copy Folder with Variable Path

tell application "Finder"
		try
			make new folder at ("/Volumes/Users/Profiles/" & theUserType & "/") with properties {name:theShortName}
			copy folder ("/Volumes/Users/Profiles/" & theUserType & "/" & theUserType & "Default/") to folder ("/Volumes/Users/Profiles/" & theUserType & "/" & theShortName & "/")
		end try
	end tell

That’s my script. Earlier in the script it mount a server with the share name /Users/. I need it to create a new folder in the /Profiles/ directory for example: /Volumes/Users/Profiles/students/thestudentsname. theUserType is set earlier as students and theShortName is set to a students name. I do not understand why this will not work.

Also, is there a way to set the owner and permissions on the folder after the contents are copied to it? Just like a chown and chmod? Thanks!

	tell application "Finder"
		try
			make new folder at ("Users:Profiles:" & theUserType & ":") with properties {name:theShortName}
			copy folder ("Users:Profiles:" & theUserType & ":" & theUserType) to folder ("Users:Profiles:" & theUserType & ":" & theShortName)
		end try
	end tell

I changed the script to the above. It now (semi) works. It copies the appropriate files except rather than the contents being within the theShortName directory, it is in theShortName/theUserType/. I need to copy the contents of the folder rather than the actual folder. After that, I need to change the permissions. Thanks in advance!

How about this?

tell application "Finder"
	try
		duplicate alias ("Users:Profiles:" & theUserType & ":" & theUserType)
		set name of result to theShortName
	end try
end tell

Would that create an alias to it, or physically make a copy? It needs to be a copy. (I would check for myself but as it’s a network account and I’m not at work, that could be difficult :stuck_out_tongue: ) Thanks for the prompt reply!

It will physically duplicate the folder.

Awesome! Thanks!

Now is there an easy way to set the permissions/owner? Or do I have to call a shell script?