Copying group of folders and renaming

I had some really great help a few months ago with a 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.


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

Work (main folder)

(sub folder)

ARTWORK (sub folders)
VISUALS

I’m not sure how this can be achieved but ideally I would like a dialog box to appear during the running of the script to ask me ‘What is the job number?’ and ‘What is the phase number?’ and ‘What is the job name?’. This hopefully fills in the required variables and copies all the folders as it did before but with the relevant naming done for me!

Not much to ask!!! :? Hmmm, OK a lot to ask but gratitude will be flooding your way if you can help!!

Many thanks.

display dialog is used for interactivity. By adding “default answer “String that is the default answer”” after the display dialog, the user will get a window with your question and underneath an editable space with the default answer displayed. Empty quotes will give an empty editable space.

set jobName to text returned of (display dialog "What is the job name?" default answer "")

Ask a question for each variable and assign by using the text returned.

Check out the Standard Additions dictionary for all the chewy goodness of display dialog.

Thanks you very much for your help but 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!


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 leaving the rest of the folder’s name, 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 the message board and Apple’s scripts to try and piece it all together with no luck!

I would so appreciate any help to solve this.

Many thanks again!

You succed make my head hurt! :-).

You should give one real example. For example you seems mention that “jobNumber Stuff” needs to become “4125 Stuff” but you doens’t explain how you make the link between jobNumber and 4125

4125 will be the answer given in the dialog box with the question “What is the Job Number”.