The following code performed flawlessly with dropped folder input from a Windows 2000 hosted AFP share but now that I’m using a Windows 2003 SMB share it fails. The highlighted code is where it falls apart. It seems once I go to rename a folder and move it I can either have the code rename it or move it but not both. It also does not matter what order I do it in. If I rename and then move - the move fails. If I fail and then rename the rename fails. I’ve had a few coders who are not necc. proficient in AppleScript look it over and we’ve not been able to find what is going wrong. Hopefully someone here will identify the problem easily.
Below is the problem block of code first, followed by the complete script.
Thanks.
Reggie
:::PROBLEM BLOCK OF CODE:::
– Rename the UserDefinedFolders Folder and move it to backup
set the name of UDF_Alias to job_name
display dialog UDF_Alias
move folder UDF_Alias to backup
– end rename and move
:::COMPLETE SCRIPT:::
on open (dropped_folders)
– Test input for folder input only - terminating on any other package
Test_Input(dropped_folders) – See subroutine by Ray at bottom
--initialize Counters, Failed to backup job list, and set the backup destination
set TheCount to 0
set ErrList to {}
set backup to ":Volumes:ARAXIVOLUME_HW09684_J:Jobs:Backup" as alias
-- end initialization
repeat with job_folder in dropped_folders
try
tell application "Finder"
set job_name to (name of job_folder)
set UDF_Exists to exists (folder "UserDefinedFolders" of folder job_folder)
if UDF_Exists then
set UDF_Alias to (job_folder & "UserDefinedFolders") as string
set UDF_Alias to UDF_Alias as alias
set Exports_Exists to exists (folder "Exports" of folder UDF_Alias)
if Exports_Exists then
--delete empty folders
set UDF_Contents to (every folder in folder UDF_Alias)
repeat with Test_folder in UDF_Contents
set Itms to (items in Test_folder)
if (count of Itms) is 0 then delete Test_folder
end repeat
-- end empty folder deletion routine
-- Rename the UserDefinedFolders Folder and move it to backup !!!!PROBLEM BLOCK!!!!
set the name of UDF_Alias to job_name
display dialog UDF_Alias
move folder UDF_Alias to backup
-- end rename and move
-- This is the successfully backed up counter
set TheCount to (TheCount + 1)
end if
end if
end tell
on error errmsg
display dialog "There was an error processing " & job_name & return & "Click Ok to Continue"
set ErrList to ErrList & job_name & return
end try
end repeat
activate me
if ErrList = {} then
display dialog (TheCount as string) & " jobs were renamed and moved to backup"
else
display dialog (TheCount as string) & " jobs were renamed and moved to backup" & return & ¬
"The Following jobs returned errors:" & return & ErrList
end if
end open
– Test for folder SubRoutine by Ray
on Test_Input(droppedItems)
repeat with i in droppedItems
set info_for to info for i
if folder of info_for is false ¬
or package folder of info_for is true then
display dialog “This application will process only folders.”
error number -128 – terminate script
end if
end repeat
– display dialog “All items are folders.” – remove after test
end Test_Input
:::END OF SCRIPT:::
Model: PPC G5 2x2Ghz 4GB Ram
AppleScript: 1.10.7
Browser: Safari 525.20.1
Operating System: Mac OS X (10.5)