-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreateFolders.scpt
67 lines (54 loc) · 1.92 KB
/
CreateFolders.scpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(*
Creates folders for a split job ticket.
*)
--set the source_folder to choose folder with prompt "Folder containing items to edit:"
-- get the path to the folder of the front window
-- if no windows are open, the desktop folder will be used
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
repeat
display dialog "Enter Job Number:" default answer "" buttons {"Cancel", "OK"} default button 2
set the job_number to the text returned of the result
if the job_number is not "" then exit repeat
end repeat
repeat
display dialog "Enter Customer:" default answer "" buttons {"Cancel", "OK"} default button 2
set the customer_name to the text returned of the result
if the customer_name is not "" then exit repeat
end repeat
repeat
display dialog "Enter Number of Parts:" default answer "1" buttons {"Cancel", "OK"} default button 2
set job_parts to (the text returned of the result) as integer
if class of job_parts is integer then exit repeat
end repeat
-- Add subfolders to a given parent folder
on addFolders(pf)
tell application "Finder"
make new folder at pf with properties {name:"PRINT"}
make new folder at pf with properties {name:"Source Files"}
make new folder at pf with properties {name:"Art"}
end tell
end addFolders
tell application "Finder"
set parentFolder to make new folder at source_folder with properties {name:job_number & "." & customer_name}
if job_parts > 1 then
repeat with i from 0 to (job_parts - 1)
set suffix to ""
if i > 0 then
set suffix to "."
if i < 10 then
set suffix to suffix & "0"
end if
set suffix to suffix & i
end if
set newFolder to make new folder at parentFolder with properties {name:job_number & suffix}
my addFolders(newFolder)
end repeat
else
my addFolders(parentFolder)
end if
beep 2
end tell