Hi all,
I have been searching for a forum to help me with my AppleScript as I am totally stumped. I have been writing this script now for about 2 months and have almost completed it until I hit one last error.
The script is doing the follow.
· Getting various information from the user
· Copying a template folder (with sub-folders) to a user specified location.
· Then renaming the folder names according to the user information
I have excerpted the final section of the script when whenever i execute gives the the error code Finder is out of memory.
I have tried making an application of the script and increasing its memory to 50000meg and it still gives me the same error
Here is the code. I am getting the entire contents of the user specified folder and making them into a string. When I try to rename them I get that error.
tell application “Finder”
activate
set fileList to entire contents of folder “000-AAA_[Title23CharsMax] copy” of disk “Odette’s Files” as list
set name of folder item 1 of list fileList to “success”
display dialog “Success!!!”
end tell
nb: Item 1 returns 243 items.
I need to make it so I can rename folders whenever the user specifies a location, which is put into the variable ‘destination_folder’ however I keep getting this error. If anyone knows of a more efficient way either I would also appreciate the feedback.
If ANYONE can help me with this piece of script, or the entire script, I would be eternally grateful. The script is not terribly difficult I just feel that there is something simple I am missing…
I have included the total script at the bottom. It looks daunting but it is really very simple. I am not too proficient in AppleScript yet.
Thanks all,
Dave.
property masterFile : {alias "Odette's Files:000-AAA_[Title23CharsMax]:"}
repeat
try
set dialogResultJob to (display dialog "What is the job No of the new project?¬
###-AAA_Name
Max length " default answer "123 - AAA_Name" with icon 1)
set theTextjob to text returned of dialogResultJob --coercion job to text
set theButtonjob to button returned of dialogResultJob --this is required even though we only need text above
on error errMessage number errNum
if errNum = -128 then
display dialog "The user hit cancel!" buttons {"Exit"} default button 1
if button returned of result = "Exit" then
error number -128
end if
else
display dialog "An error occurred: " & errMessage
end if
end try
if the (count of theTextjob) < 32 then
exit repeat
end if
end repeat
try
set dialogResultAuthor to (display dialog "What is the Author and edition?¬
Author -1Ed
Max length " default answer "Author -1Ed" with icon 1)
set theTextAuthor to text returned of dialogResultAuthor --coercion Author Name to text
set theButtonAuthor to button returned of dialogResultAuthor --this is required even though we only need text above
on error errMessage number errNum
if errNum = -128 then
display dialog "The user hit cancel!" buttons {"Exit"} default button 1
if button returned of result = "Exit" then
error number -128
end if
else
display dialog "An error occurred: " & errMessage
end if
end try
try
set dialogResultBookTitle to (display dialog "What is the Book title and edition?¬
Book title-1Ed¬
Max length " default answer "Book title-1Ed" with icon 1)
set theTextBookTitle to text returned of dialogResultBookTitle --coercion Book Title to text
set theButtonBookTitle to button returned of dialogResultBookTitle --this is required even though we only need text above
on error errMessage number errNum
if errNum = -128 then
display dialog "The user hit cancel!" buttons {"Exit"} default button 1
if button returned of result = "Exit" then
error number -128
end if
else
display dialog "An error occurred: " & errMessage
end if
end try
repeat
try
set dialogResultISBN to (display dialog "What is the ISBN ?
10 digits with no spaces or dashes
Max
" default answer "01701*****" with icon 1)
on error errMessage number errNum
if errNum = -128 then
display dialog "The user hit cancel!" buttons {"Exit"} default button 1
if button returned of result = "Exit" then
error number -128
end if
else
display dialog "An error occurred: " & errMessage
end if
end try
set theTextISBN to text returned of dialogResultISBN --coercion ISBN to text
if the theTextISBN != "01701*****" and (count theTextISBN) = 10 then
exit repeat
end if
end repeat
set theISBN to "ISBN" & theTextISBN --coercion ISBN to text
set theButtonjob to button returned of dialogResultISBN --this is required even though we only need text above
display dialog (theTextjob & " " & theTextAuthor & " " & theTextBookTitle & " " & theISBN)
tell application "Finder"
activate
set destination_folder to choose folder with prompt "Where do you want to save the new job?…" --the new location for the object
(*if the free space of the disk of the destination_folder is less than the size of the masterFile then
error "Not enough free space to perform the action."
end if*)
set filespec to duplicate every item of masterFile to the destination_folder with replacing
filespec as string
set fileList to entire contents of folder "000-AAA_[Title23CharsMax] copy" of destination_folder as list
open destination_folder
set name of folder item 1 of list fileList to "success"
display dialog "Success!!!"
end tell
beep 2