Could someone please help. I have a script which is a job folder script for a small studio. This script generates a folder and sub-folder apon the naming string. The next part is where I’m trying to get some help, advice, or a link to explain a little (scripting newbie).
so the first stage of the script is this:
tell application "Finder"
choose folder
to set targetFolder to target of Finder window 1 as text
set jobNumber to getParameter for "Enter Job Number"
set jobTitle to getParameter for "Enter Job Title"
set folderStructure to "/{'Design'/{'1. Working','2. Output','3. Assets','4. Ref'},'Artwork'/{'• Final Artwork','• Previous Proof','Images Hi Res','PDFs'},'Copy'/{'• Previous Proof','• Copy Brief'},'Production'/{'Briefs','Estimates','Feedback','PDFs','Production','QA (Signoff)','Scope (SOW)','Specs','Timings'},'Creative'/{'1. Working','2. Output','3. Assets','4. Ref'}}"
do shell script "/bin/mkdir -p " & quoted form of POSIX path of targetFolder & "/" & quoted form of (jobNumber & "_" & jobTitle) & folderStructure
on getParameter for prompt
repeat
display dialog prompt default answer ""
set parameter to text returned of result
if result is not "" then return parameter
end repeat
end getParameter
this script generates the folders I’d like, but I have a TXT template called checklist.txt on the server. I would love a way of actionsctipt to add a duplicate of this file and add it to the ‘Production’ folder. Is it possible to do this?
try this, you’ll need to add the correct path to your text file, its quick and dirty, and can be improved i’m sure, but it will give nudge in the right direction
property mycopypath : "PATH TO YOUR TXT FILE:TEST.txt" --Addd your path
property folderStructure : "/{'Design'/{'1. Working','2. Output','3. Assets','4. Ref'},'Artwork'/{'• Final Artwork','• Previous Proof','Images Hi Res','PDFs'},'Copy'/{'• Previous Proof','• Copy Brief'},'Production'/{'Briefs','Estimates','Feedback','PDFs','Production','QA (Signoff)','Scope (SOW)','Specs','Timings'},'Creative'/{'1. Working','2. Output','3. Assets','4. Ref'}}"
tell application "Finder"
set targetFolder to choose folder
set jobNumber to text returned of (display dialog "Enter Job Number" default answer "")
set jobTitle to text returned of (display dialog "Enter Job Title" default answer "")
do shell script "/bin/mkdir -p " & quoted form of POSIX path of targetFolder & "/" & quoted form of (jobNumber & "_" & jobTitle) & folderStructure
set topFolder to targetFolder
repeat with drillDown in (get every folder of folder topFolder)
try
repeat with everyFolder in (get every folder of folder (drillDown as alias))
try
if exists (folder of everyFolder whose name is "Production") then
duplicate mycopypath to folder "Production" of everyFolder with replacing
end if
on error errorText
display dialog errorText
end try
end repeat
end try
end repeat
end tell
First of all the Finder is not needed at all except to copy the checklist file
The code asks to choose the checklist file. Later replace the choose file line with a full HFS path
set checkList to "Macintosh HD:Users:MyUser:path:to:checklist.txt"
set targetFolder to choose folder with prompt "Choose target folder"
set checkList to (choose file with prompt "Chosse CheckList file") as text
set jobNumber to getParameter for "Enter Job Number"
set jobTitle to getParameter for "Enter Job Title"
set baseFolder to (targetFolder as text) & jobNumber & "_" & jobTitle
set folderStructure to "/{'Design'/{'1. Working','2. Output','3. Assets','4. Ref'},'Artwork'/{'• Final Artwork','• Previous Proof','Images Hi Res','PDFs'},'Copy'/{'• Previous Proof','• Copy Brief'},'Production'/{'Briefs','Estimates','Feedback','PDFs','Production','QA (Signoff)','Scope (SOW)','Specs','Timings'},'Creative'/{'1. Working','2. Output','3. Assets','4. Ref'}}"
do shell script "/bin/mkdir -p " & quoted form of POSIX path of targetFolder & "/" & quoted form of (jobNumber & "_" & jobTitle) & folderStructure
tell application "Finder" to duplicate file checkList to folder "Production" of folder baseFolder
on getParameter for prompt
repeat
display dialog prompt default answer ""
set parameter to text returned of result
if result is not "" then return parameter
end repeat
end getParameter