You probably don’t know what I’m talking about, so here’s all the players.
Here’s the launch agent:
The Label can be anything, but it should be unique. Also, you might need to restart or maybe just restart Finder. Here’s the bash script it calls:
Remember to make it executable. In Terminal "chmod +x /path/to/the/script’. Here’s the AppleScript compiled script:
property drop_folder_path : "Macintosh HD:Users:kelhome:Desktop:DropFolder:"
-- call this script from shell script
on run -- p -- parameters if needed
set drop_folder_ref to drop_folder_path as alias
tell application "Finder"
set dropped_items to every item of drop_folder_ref as alias list
activate
end tell
-- move the added items back to original location
-- but first, turn off launch agent for one-shot
-- remember to re-load at end
--do shell script "launchctl unload /Users/kelhome/Library/LaunchAgents/com.apple.launchagent.plist"
tell application "System Events" to keystroke "z" using command down
-- dropped_items are now in original loacation and references should reflect that
-- testing: look at original locations
set string_list to {}
repeat with this_item in dropped_items
set end of string_list to this_item as string
end repeat
activate
choose from list string_list
-- one shot
do shell script "launchctl unload /Users/kelhome/Library/LaunchAgents/com.apple.launchagent.plist"
end run
The question is where to re-load the launch agent. Here’s the load and unload Terminal scripts:
It’s pretty quick, but where to re-load the launch agent. I need to step back and think. Getting to one track minded.
Edited: oops, forgot to add the .2 sec. delay:
property drop_folder_path : "Macintosh HD:Users:kelhome:Desktop:DropFolder:"
-- call this script from shell script
on run -- p -- parameters if needed
set drop_folder_ref to drop_folder_path as alias
tell application "Finder"
set dropped_items to every item of drop_folder_ref as alias list
activate
end tell
-- move the added items back to original location
-- but first, turn off launch agent for one-shot
-- remember to re-load at end
--do shell script "launchctl unload /Users/kelhome/Library/LaunchAgents/com.apple.launchagent.plist"
tell application "System Events" to keystroke "z" using command down
-- dropped_items are now in original loacation and references should reflect that
-- testing: look at original locations
delay 0.2 -- added this
set string_list to {}
repeat with this_item in dropped_items
set end of string_list to this_item as string
end repeat
activate
choose from list string_list
-- one shot
do shell script "launchctl unload /Users/kelhome/Library/LaunchAgents/com.apple.launchagent.plist"
end run
See the comment.
gl,
kel