Hi all,
Kind of a noob here, so I apologize if I’m not doing this correctly.
Here’s my dilemma, in the script below, I’d like to copy a file (a mortgage calculator) into the folder ‘Client Docs’, which is created once I run this script. How do I adjust the script so as to have the file populate the folder when I run this script?
Thanks in advance for your help!
set Alias1 to choose folder
set theName to text returned of (display dialog “Client Name” default answer “New Client”)
tell application “Finder”
if (folder (theName) exists) is not true then
try
set dir_1 to make new folder at Alias1 with properties {name:theName}
set dir_2 to make new folder at dir_1 with properties {name:“Prepared Docs”}
set dir_3 to make new folder at dir_1 with properties {name:“Lender Communications”}
set dir_4 to make new folder at dir_1 with properties {name:“Signed Docs”}
set dir_5 to make new folder at dir_1 with properties {name:“Client Docs”}
set dir_6 to make new folder at dir_1 with properties {name:“Property Docs”}
set theFolder to make new Finder window
set target of theFolder to folder theName
end try
end if
end tell
Hi,
first of all, the “exists” check works only if Alias1 points to the desktop folder.
A Finder window is not needed to copy Finder items.
Note: The file is only copied if the folder hierarchy is created
set Alias1 to choose folder
set theFile to choose file
set theName to text returned of (display dialog "Client Name" default answer "New Client")
tell application "Finder"
if not (exists folder theName of Alias1) then
try
set dir_1 to make new folder at Alias1 with properties {name:theName}
set dir_2 to make new folder at dir_1 with properties {name:"Prepared Docs"}
set dir_3 to make new folder at dir_1 with properties {name:"Lender Communications"}
set dir_4 to make new folder at dir_1 with properties {name:"Signed Docs"}
set dir_5 to make new folder at dir_1 with properties {name:"Client Docs"}
set dir_6 to make new folder at dir_1 with properties {name:"Property Docs"}
duplicate theFile to dir_5
end try
end if
end tell
Thanks so much Stefan. Appreciate the help!
LEvi
Hello
If the folders hierarchy already exists, this edited version would duplicate the file.
set Alias1 to choose folder
set theFile to choose file
set theName to text returned of (display dialog "Client Name" default answer "New Client")
tell application "Finder"
if not (exists folder theName of Alias1) then
try
set dir_1 to make new folder at Alias1 with properties {name:theName}
set dir_2 to make new folder at dir_1 with properties {name:"Prepared Docs"}
set dir_3 to make new folder at dir_1 with properties {name:"Lender Communications"}
set dir_4 to make new folder at dir_1 with properties {name:"Signed Docs"}
set dir_5 to make new folder at dir_1 with properties {name:"Client Docs"}
set dir_6 to make new folder at dir_1 with properties {name:"Property Docs"}
duplicate theFile to dir_5
end try
else
duplicate theFile to folder ((Alias1 as text) & theName & ":Client Docs:")
end if
end tell
Yvan KOENIG (VALLAURIS, France) jeudi 21 mars 2013 18:40:51