Wednesday, December 8, 2021

#1 2009-07-06 03:55:46 am

AKazak
Member
From:: Moscow
Registered: 2009-07-06
Posts: 31

Duplicate folder + change folder name...

Greetings!

I use sample script to dulplicate a folder.

Applescript:

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 ..."


Filed under: Finder

Offline

 

#2 2009-07-06 04:45:45 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11755
Website

Re: Duplicate folder + change folder name...

Hi,

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


regards

Stefan

Offline

 

#3 2009-07-06 06:47:47 am

AKazak
Member
From:: Moscow
Registered: 2009-07-06
Posts: 31

Re: Duplicate folder + change folder name...

StefanK wrote:

duplicate the folder with the Finder and rename it afterwards


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?

Offline

 

#4 2009-07-06 06:57:24 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11755
Website

Re: Duplicate folder + change folder name...

the folder might be locked or you have insufficient privileges.

You can unlock a folder with

Applescript:

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


regards

Stefan


Filed under: Finder

Offline

 

#5 2009-07-06 09:02:50 am

AKazak
Member
From:: Moscow
Registered: 2009-07-06
Posts: 31

Re: Duplicate folder + change folder name...

Thank you very much!
wink

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)