Copy folder and rename certain variables within folder names.
Copy folder and rename certain variables within folder names.
- Subject: Copy folder and rename certain variables within folder names.
- From: Tim Morton <email@hidden>
- Date: Thu, 28 Aug 2003 14:43:14 +0100
Hi I hope you can help!
I had some really great help a few months ago from an AppleScript website
regarding a OSX script I was having trouble with and am happy to say it
works fine. It basically copies a hierarchy of folders from my hard drive
into the current window that's open.
Code:
try
tell application "Finder" to set the source_folder to (folder of the
front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
tell application "Finder"
duplicate folder "Folder1:Folder2:<Job Number> Work" in the startup disk
to source_folder
end tell
I am very new to AppleScript so am having real trouble knowing where to
start changing the current script so it becomes even more useful.
What I need to accomplish is to copy the folder required as before but
rename some of them. There needs to be variables which have to be filled in
every time the folder is copied e.g.
<Job Number> Work (main
folder)
<Job Number><Phase Number><Job name> (sub folder)
<Job Number><Phase Number> ARTWORK (sub folders)
<Job Number><Phase Number> VISUALS
I sent this information and had a reply back with a few clues on how to
sript dialog boxes. It only half works and I'm pretty sure I don't have a
clue what I'm doing!
This is the code so far and the dialogs do ask me all the right questions
but I have a hunch that I'm missing so much out!
Code:
try
tell application "Finder" to set the source_folder to (folder of the
front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try
tell application "Finder"
set jobNumber to text returned of (display dialog "What is the job
number?" default answer "")
set jobPhase to text returned of (display dialog "What is the job phase?"
default answer "")
set jobName to text returned of (display dialog "What is the job name?"
default answer "")
duplicate folder "Folder1:Folder2:jobNumber Stuff" in the startup disk to
source_folder
end tell
I need the script to change all the folder names within the folder hierarchy
and change only jobName, jobPhase and jobName in each folder (wherever it
occours within the folder hierarchy) leaving the rest of the folder's name
alone, e.g.
(Folder) "jobNumber Stuff" needs to become "4125 Stuff" and
(sub Folder) "jobNumber.jobPhase jobName" needs to become "4125.001 This is
the name of job".
So the dialog box asks me "What is the job Number?" and it will place my
answer where all occurrences of "jobNumber" is within the folder hierarchy.
I hope this makes sence!
I'm a bit concerned this is too complicated for me to get my head round and
my head is already starting to hurt with trying to figure any of this out! I
have looked through message boards and Apple's scripts to try and piece it
all together with no luck! Is there a problem with how the folders are
named?
I would so appreciate any help to solve this.
Many thanks.
Tim
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.