Hey,
New to AppleScripts and MacScripter but looking forward to contributing to the community and learning as much as possible.
For no obvious reason, I was asked by work to create a script that does the following:
On dropping file(s) to the script, a dialogue box pops up asking for the name of the agency the work they’re dropping is for. After that text is input, AS searches a specific network drive for that agency’s folder and if there’s more than one folder with the agency’s name, those names come back for the user to select the correct one (I don’t expect this to happen but just in case). If there are no folders with that agency’s name, a dialogue box asks for the name of the new folder/agency and AS creates that folder on the network drive. If there’s only one folder listed in the directory with that agency, then AS compresses the files we dragged to the script adding today’s date [format: 01_25 for today] and puts them in that folder. On finish, new finder window launches showing the compressed file(s) in their proper directory.
So, this is what I’ve compiled so far -
This is my master script that I’m trying to build on, the components I’ve lifted from other users and are listed below this:
on open (theItems)
with timeout of 1000000 seconds
set temp to display dialog "Enter the name of the Agency this project is for" default answer ""
set text_user_entered to the text returned of temp
set variable1 to text_user_entered
try
tell application "Finder"
repeat with oneItem in theItems
set itemProp to properties of oneItem
set itemPath to quoted form of POSIX path of oneItem
set destFold to quoted form of POSIX path of ¬
(container of itemProp as alias)
set itemName to name of oneItem
do shell script ¬
("ditto -c -k -X --rsrc --keepParent " & itemPath & ¬
" " & destFold & "'" & itemName & "'" & ".zip")
end repeat
end tell
on error errmsg
display dialog "sorry, didn't work. give ben a fail cookie."
end try
end timeout
tell application "Finder"
open location "" --network path
end tell
end open
That obviously doesn’t do all that I’m trying to do so I’m trying to figure out a way to finesse what I found into one awesome, working apple script - here’s what I’m working with:
This compresses dropped files, I was using this because if the user drags multiple files it compresses them individually:
on open (theItems)
with timeout of 1000000 seconds
try
tell application "Finder"
repeat with oneItem in theItems
set itemProp to properties of oneItem
set itemPath to quoted form of POSIX path of oneItem
set destFold to quoted form of POSIX path of ¬
(container of itemProp as alias)
set itemName to name of oneItem
do shell script ¬
("ditto -c -k -X --rsrc --keepParent " & itemPath & ¬
" " & destFold & "'" & itemName & "'" & ".zip")
end repeat
end tell
on error errmsg
display dialog "sorry, didn't work. give ben a fail cookie."
end try
end timeout
end open
This is what I used for the dialogue input box:
set temp to display dialog "Enter the name of the Agency this project is for" default answer ""
set text_user_entered to the text returned of temp
Open a network drive:
tell application "Finder"
open location "afp://user:password@server/share"
end tell
And finally, renaming files so current date is added:
set thepath to {"drive:path"}
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
set incomingDate to (current date)
set numYear to year of incomingDate as number
set textYear to text -2 through -1 of (numYear as string)
set JobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
set JobNumName to JobNum & "_" & JobName
set new_sub_list to {{"AfterEffects", {"Assets", "Projects"}}, {"FinalCutPro", {"Assets", "Projects"}}, {"Reference_Material"}, {"Audio"}, {"Pitch_Material"}, {"Agency_Boards_Scripts"}, {"Artwork"}}
I realize this is a lot so I doubly appreciate anything anyone can do to contribute, even if that means just pointing me in the right direction.
Thanks again and cheers,
Ben
Model: Mac Pro Dual G5 2.5Ghz
AppleScript: 1.10.7
Browser: Firefox 3.6
Operating System: Mac OS X (10.4)