Hello I am having difficulty to finish the following script. For info I am running Mavericks with Numbers 09.
I would like the script to Check if some folders exist and if not create them as follows on my desktop:
Temp ITP Inquiry Timming Process
ITP from KIKI
ITP to be uploaded to Kiki
ClientFolderNameFor_ITP
ITP Old
Then when all folders are either existing or newly created I would like to save and close a Numbers document as follows:
Temp ITP Inquiry Timming Process
ITP from KIKI
ITP to be uploaded to Kiki
ClientFolderNameFor_ITP
new_ITPFileName.numbers
ITP Old
So far my script creates the following
Temp ITP Inquiry Timming Process
{“ITP from KIKI”, “ITP to be uploaded to Kiki”, “ITP Old”}
ClientFolderNameFor_ITP
My list do not show as single folders and it cannot nest my folder “ClientFolderNameFor_ITP” in the desired folder “ITP to be uploaded to Kiki” and finally it cannot save my numbers document into the folder “ClientFolderNameFor_ITP”.
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set A33 to (value of cell "A33") as text -- Set client folder name for ITP
set B41 to (value of cell "B41") as text -- Set the ITP file name
end tell
end tell
property MasterShareFolder : "Temp ITP Inquiry Timming Process"
property folderList : {"ITP from KIKI", "ITP to be uploaded to Kiki", "ITP Old"}
set ClientFolderNameFor_ITP to A33
set new_ITPFileName to B41
set {TID, text item delimiters} to {text item delimiters, ","}
set theFolders to folderList as text
set text item delimiters to TID
-- create folders in case they don't exist
do shell script "/bin/mkdir -p " & quoted form of (POSIX path of (path to desktop) & MasterShareFolder & "/{" & folderList & "}/" & ClientFolderNameFor_ITP)
-- Save and close Numbers document
tell application "Numbers"
save document 1 in desktop & ":" & MasterShareFolder & ":" & ClientFolderNameFor_ITP & ":" & B41 as string
close document 1 saving no
end tell
-- Display Message to show what just happened
display dialog "File: " & new_ITPFileName & " Created in " & ClientFolderNameFor_ITP & " in Desktop folder " & MasterShareFolder
Hope anyone can help!
to get your desired folder structure with mkdir, the syntax must be
property MasterShareFolder : "'Temp ITP Inquiry Timming Process'"
property folderList : "'ITP from KIKI','ITP to be uploaded to Kiki'/ClientFolderNameFor_ITP,'ITP Old'"
do shell script "/bin/mkdir -p " & quoted form of POSIX path of (path to desktop) & MasterShareFolder & "/{" & folderList & "}"
Thanks for the answer it works great but I have a bit of a problem saving my Numbers document in the proper folder?
The syntax works well for creating the proper folders except that the nested folder should not be a proper sentence but a variable from my opened Numbers document cell “A33”
I tried to place in the following my cell reference but it did not work? I bolded my adjustment…
property folderList : “‘ITP from KIKI’,‘ITP to be uploaded to Kiki’/A33,‘ITP Old’”
Finally could you help me as well with the syntax to save the numbers document in the proper folder?
It should be saved inside the created folder using the cell reference “A33”
Would the script below work? as now it hangs and finally shows a error message? It seems that I am missing one folder in my below script but do not know how to make it appear? A33 should nested in the folder “ITP to be uploaded to Kiki”
-- Save and close Numbers document
tell application "Numbers"
save document 1 in desktop & ":" & MasterShareFolder & ":" & A33 & ":" & B41 as string
close document 1 saving no
end tell
property MasterShareFolder : "'Temp ITP Inquiry Timming Process'"
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set ClientFolderNameFor_ITP to (value of cell "A33") as text -- Set client folder name for ITP
set new_ITPFileName to (value of cell "B41") as text -- Set the ITP file name
end tell
end tell
set folderList to "'ITP from KIKI','ITP to be uploaded to Kiki'/" & quoted form of ClientFolderNameFor_ITP & ",'ITP Old'"
-- create folders in case they don't exist
do shell script "/bin/mkdir -p " & quoted form of POSIX path of (path to desktop) & MasterShareFolder & "/{" & folderList & "}"
set destinationFilePath to (path to desktop as text) & MasterShareFolder & ":ITP to be uploaded to Kiki:" & ClientFolderNameFor_ITP & ":" & new_ITPFileName
-- Save and close Numbers document
tell application "Numbers"
save document 1 in destinationFilePath
close document 1 saving no
end tell
tell application “Numbers”
save document 1 in “Macintosh HD:Users:clbair2012:Desktop:‘Temp ITP Inquiry Timming Process’:ITP to be uploaded to Kiki:ELL - elioTeknology ltd:ITP_ELLi14021101_-_500Pcs_Plastic_Recorder Microphone Shape_M6”
Result:
error “Numbers got an error: AppleEvent timed out.” number -1712
It seems that it does not save the file as a numbers file anyway? Is that the problem?
set destinationFilePath to (path to desktop as text) & MasterShareFolder & ":ITP to be uploaded to Kiki:" & ClientFolderNameFor_ITP & ":" & new_ITPFileName & ".numbers"
I tried that solution already but it generates 2 sets of different nested folders with one with quoted signs that will hold my saved file but in this structure the list does not appear.
-- Save and close Numbers document
tell application "Numbers"
save document 1 in (path to desktop as text) & MasterShareFolder & ":ITP to be uploaded to Kiki:" & ClientFolderNameFor_ITP & ":" & new_ITPFileName & ".numbers"
close document 1 saving no
end tell
By removing the single quote I go back to one of my original problems as not to create my directories here is the results lines.
tell application “Numbers”
get value of cell “A33” of table 1 of sheet 1 of document 1
→ “TIE - Titrachi Event”
get value of cell “B41” of table 1 of sheet 1 of document 1
→ “ITP_TIEi14013001_-_500Pcs_Plastic_Recorder Microphone Shape_M6”
end tell
tell current application
path to desktop
→ alias “Macintosh HD:Users:clbair2012:Desktop:”
do shell script “/bin/mkdir -p '/Users/clbair2012/Desktop/'Temp ITP Inquiry Timming Process/{‘ITP from KIKI’,‘ITP to be uploaded to Kiki’/‘TIE - Titrachi Event’,‘ITP Old’}”
→ error “mkdir: ITP: Permission denied
mkdir: Inquiry: Permission denied
mkdir: Timming: Permission denied
mkdir: Process/ITP from KIKI: Permission denied
mkdir: Process/ITP to be uploaded to Kiki/TIE - Titrachi Event: Permission denied
mkdir: Process/ITP Old: Permission denied” number 1
Result:
error “mkdir: ITP: Permission denied
mkdir: Inquiry: Permission denied
mkdir: Timming: Permission denied
mkdir: Process/ITP from KIKI: Permission denied
mkdir: Process/ITP to be uploaded to Kiki/TIE - Titrachi Event: Permission denied
mkdir: Process/ITP Old: Permission denied” number 1
I finally got an acceptable result by modifying the property line with underscores in between the words but best would be to show the master folder without underscores…
Here is the script modified if you can help with this final little glitch would be great…
Anyway thanks for your time and efforts.
property MasterShareFolder : "Temp_ITP_Inquiry_Timming_Process"
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set ClientFolderNameFor_ITP to (value of cell "A33") as text -- Set client folder name for ITP
set new_ITPFileName to (value of cell "B41") as text -- Set the ITP file name
end tell
end tell
set folderList to "'ITP from KIKI','ITP to be uploaded to Kiki'/" & quoted form of ClientFolderNameFor_ITP & ",'ITP Old'"
-- create folders in case they don't exist
do shell script "/bin/mkdir -p " & quoted form of POSIX path of (path to desktop) & MasterShareFolder & "/{" & folderList & "}"
-- Save and close Numbers document
tell application "Numbers"
save document 1 in (path to desktop as text) & MasterShareFolder & ":ITP to be uploaded to Kiki:" & ClientFolderNameFor_ITP & ":" & new_ITPFileName & ".numbers"
close document 1 saving no
end tell
property MasterShareFolder : "Temp ITP Inquiry Timming Process"
tell application "Numbers"
tell table 1 of sheet 1 of document 1
set ClientFolderNameFor_ITP to (value of cell "A33") as text -- Set client folder name for ITP
set new_ITPFileName to (value of cell "B41") as text -- Set the ITP file name
end tell
end tell
set folderList to "'ITP from KIKI','ITP to be uploaded to Kiki'/" & quoted form of ClientFolderNameFor_ITP & ",'ITP Old'"
-- create folders in case they don't exist
do shell script "/bin/mkdir -p " & quoted form of POSIX path of (path to desktop) & quoted form of MasterShareFolder & "/{" & folderList & "}"
-- Save and close Numbers document
set destinationFilePath to (path to desktop as text) & MasterShareFolder & ":ITP to be uploaded to Kiki:" & ClientFolderNameFor_ITP & ":" & new_ITPFileName & ".numbers"
tell application "Numbers"
save document 1 in file destinationFilePath
close document 1 saving no
end tell