Duplicate folder + change folder name...


I use sample script to dulplicate a folder.

set SourceFolder to alias ((path to desktop folder as text) & "TestFolder")
set destinationFolder to alias ((path to documents folder as text))

tell application "Finder"
duplicate SourceFolder to destinationFolder
end tell

Is there any way to specify here the name of duplicated folder?
I mean to do something like “duplicate … to … with name …”


AppleScript can’t do this directly. Either you duplicate the folder with the Finder and rename it afterwards
or you duplicate the folder with the shell. /bin/cp or /usr/bin/ditto can move and rename at the same time.

Note: path to documents folder returns an alias, the coercion to text and back to alias is useless

Thank you, Stefan!

Actually I duplicate a whole CD folder. To walk the first way I need to clear read-only attribute from duplicated folder before renaming it.
Is there any way to modify the attributes of a folder with its contents by means of AppleScript?

the folder might be locked or you have insufficient privileges.

You can unlock a folder with

tell application "Finder" to set locked of folder "path:to:myFolder" to false

To change access privileges you need admin rights, then you can change owner and group with chown
and the privileges with chmod.
chown and chmod are shell commands

Thank you very much!