I found a code snippet when searching in the forums, but when trying to implement it myself it won’t work at all!
on replaceText(find, replace, subject)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to find
set subject to text items of subject
set AppleScript's text item delimiters to replace
set subject to "" & subject
set AppleScript's text item delimiters to prevTIDs
return subject
end replaceText
on adding folder items to dir after receiving theitem
try
set directory to dir as string
set filePlace to theitem as string
set folderNameLength to length of directory as integer
set fileName to characters (folderNameLength + 1) thru -1 of filePlace as string
set theAddress to "http://url.com/" & fileName as string
set the theAddress to replaceText(" ", "%20", theAdress)
set the clipboard to theAddress
tell application "GrowlHelperApp"
set defaultNotification to "Put address on Clipboard"
set myAllNotesList to {defaultNotification}
register as application defaultNotification all notifications myAllNotesList default notifications {defaultNotification} icon of application "Finder.app"
notify with name defaultNotification title defaultNotification description "" & theAdress & " has been put on the clipboard" application name defaultNotification
end tell
on error
tell application "GrowlHelperApp"
set defaultNotification to "Put address on Clipboard"
set myAllNotesList to {defaultNotification}
register as application defaultNotification all notifications myAllNotesList default notifications {defaultNotification} icon of application "Finder.app"
notify with name defaultNotification title defaultNotification description "Something went terribly wrong! :o" application name defaultNotification
end tell
end try
end adding folder items to
What the code is supposed to do is to take the file name of the file I dropped in a specific folder and then add “http://url.com/filename” to the clipboard. Everything works just fine except separating the filename from its destination. Do you have any suggestions what I’m doing wrong, or how it can be done in some other way?
Thanks!