Skip to content

Instantly share code, notes, and snippets.

@g-r-a-v-e-l-y
Last active November 4, 2022 18:56
Show Gist options
  • Save g-r-a-v-e-l-y/1362655 to your computer and use it in GitHub Desktop.
Save g-r-a-v-e-l-y/1362655 to your computer and use it in GitHub Desktop.
An applescript folder action that moves downloaded torrent files to a different directory.
on adding folder items to thisFolder after receiving added_items
mount volume "afp://user@host/share"
delay 1
repeat with addedFile in added_items
tell application "Finder"
if (the name of the addedFile ends with "torrent" or "nzb") then
display notification "Queueing " & (name of addedFile) & "."
try
tell application "Finder"
move addedFile to "spool" with replacing
delete addedFile
end tell
on error
display alert "Unable to move " & (name of i)
end try
end if
end tell
end repeat
end adding folder items to
@SawkeeReemo
Copy link

If you're still around to see this, this is great! Thanks! I was just trying to do the same thing but somehow sent my torrent file into the ether. I didn't have the repeat addedFile in added_items in mine, so I have no idea where it landed. 🤣

Question: in your display dialog, what does name of i mean? That's the only part I'm guessing on. I'm assuming it takes the file name of any error'd file and displays it, but what is the exact meaning? Is it "name of input"? Google search didn't help me here. Thanks!

@g-r-a-v-e-l-y
Copy link
Author

Ah, that is probably a bug. I think I gisted this in a hurry to show someone in IRC or something. I don't use directory watch anymore, I just use curl and my torrent client equivalent like this: https://gist.github.com/g-r-a-v-e-l-y/35a91ca9948700b00b6a043cfcbaeb3d

@SawkeeReemo
Copy link

Oh cool. Thanks for sharing that! I’m going to dig in on that later. I’m still learning scripting, but have managed to make some pretty cool automations. Thanks for sharing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment