In Jaguar, I had the following folder action script, which imported pictures added to the folder into iPhoto:
on adding folder items to this_folder after receiving these_items
set this_item to this_folder
-- convert the file reference to UNIX style
set this_path to the POSIX path of this_item
--prompt for import -this ensures all photos have been downloaded from the camera before starting import
display dialog "Import these Photos to iPhoto? (If yes, wait until download from camera is complete)" buttons {"Yes", "No"} default button 1
if button returned of the result is "Yes" then
-- bring the target application to the front
tell application "iPhoto"
activate
try
tell application "System Events"
tell process "iPhoto"
-- summon the import dialog
click menu item "Import?" of menu "File" of menu bar 1
-- enter the path to the image in the dialog input
set the «class valu» of text field 1 of group 1 of group 2 of window "Import Photos" to this_path
delay 1
-- click to start the import
click button "Import" of window "Import Photos"
if the last character of (this_item as string) is ":" then
-- it's a folder so click the import button again
click button "Import" of window "Import Photos"
end if
end tell
end tell
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell
--prompt for deletion of originals -may want to keep originals for separate editing or archiving
display dialog "Delete Originals?" buttons {"Yes", "No"} default button 2
if button returned of the result is "Yes" then
tell application "Finder" to delete items of this_folder
end if
end if
end adding folder items to
However, since the GUI elements in Panther are completely different, this script doesn’t work. For example, there is no longer any text field in the Import dialog in which to put the “Import from” path. I didn’t write the GUI portion of the script, I just added the dialogs to suit my needs, and I’m barely an amateur scripter. Any idea how to get this to work, or at least how to do what I want to do?
Thanks in advance for the help.
–m_d
The best advice is to download the UI Browser from Apple and point it at the field and see if you can guess what the path to the field is supposed to be. Amateur scripters get better with practice.
Once you’ve tried to fix the problem, post other questions and help should be more forthcoming.
I do have the UI Browser, and I did try it, but like I said, the Import… dialog box in Panther no longer has a path input field like the one in Jaguar. And since the script passes the path of the folder to which this action is attached to that text field in the Import… dialog (at least it did in Jaguar), so that the pics in that folder are imported into iPhoto using that dialog, the script doesn’t work in Panther. So I guess what I’m asking is how to pass the path of the folder with the action script to the Import dialog, since there’s no longer a text field to tell the Import… dialog what folder to import the pics from. Know whatta mean, Vern?
I found the answer I was looking for in this thread.
Here’s the modified, and now working, script:
on adding folder items to this_folder after receiving these_items
set this_item to this_folder
-- convert the file reference to UNIX style
set this_path to the POSIX path of this_item
--prompt for import -this ensures all photos have been downloaded from the camera before starting import
display dialog "Import these Photos to iPhoto? (If yes, wait until download from camera is complete)" buttons {"Yes", "No"} default button 1
if button returned of the result is "Yes" then
-- bring the target application to the front
tell application "iPhoto"
activate
try
tell application "System Events"
tell process "iPhoto"
-- summon the import dialog
click menu item "Import?" of menu "File" of menu bar 1
-- enter the path to the image in the dialog input
delay 5
keystroke "G" using command down --uppercase G
delay 2
keystroke this_path
delay 1
keystroke return
delay 1
-- click to start the import
click button "Import" of window "Import Photos"
end tell
end tell
on error error_message
display dialog error_message buttons {"OK"} default button 1
end try
end tell
--prompt for deletion of originals -may want to keep originals for separate editing or archiving
display dialog "Delete Originals?" buttons {"Yes", "No"} default button 2
if button returned of the result is "Yes" then
tell application "Finder" to delete items of this_folder
end if
end if
end adding folder items to
Perhaps not the most elegant solution, but it gets the job done.
Actually, I didn’t. I’m glad you got your solution and were thoughtful to post it.