Anyone know how to get a file name from a repeat loop to display in a Growl notification? I have a folder set up that automatically moves any file placed in it into a folder on a network drive after a certain amount of time. I set it up in Automator, but it always bugged me that the Growl notification wouldn’t display WHICH file has been moved, but just a preprogrammed message. I figured it would be easy in Applescript, but I’m running into a wall.
set icon_file to "2074:Users:admin:Desktop:eps.png" as alias
set FilePath to (path to desktop as string) & "1" as alias
try
tell application "Finder"
set fileList to every file of folder FilePath as alias list
end tell
end try
try
repeat with aFile in fileList
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"EPS_Moved"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬
{"EPS_Moved"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Move EPS" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
-- Send a Notification...
notify with name ¬
"EPS_Moved" title ¬
"EPS file moved" description ¬
aFile & " has been moved to Archive:EPS ADS" application name ¬
"Move EPS" image from location icon_file
end tell
end repeat
end try
HAH! Never mind. I just figured it out. I’ll still post in case someone else has the same problem…
I changed the line
aFile & " has been moved to Archive:EPS ADS" application name ¬
to
(aFile & " has been moved to Archive:EPS ADS") as string application name ¬
and it worked like a charm. The first line would give me the proper notifications, but with blank text. The second line gives me something like “2074:Users:admin:Desktop:1:998765.eps has been moved to Archive:EPS ADS”.
Now that I have that figured out, it should be simple to modify the code to strip out the file path and just give me the file name.