[OSX] Moving Files after downloads

Come up with a useful post-processing script? Share it here!
Post Reply
gonzo112
Newbie
Newbie
Posts: 1
Joined: January 5th, 2013, 9:23 am

[OSX] Moving Files after downloads

Post by gonzo112 »

Hello Everybody

I looked at quite a lot of scripts but can't get my head around why this is not working for me. I hope one of you can help me out with the two questions i have:

1:

I am using the following script to move my files to my NAS:

Code: Select all

#!/bin/bash
if [ "$5" = "movies" ]; then
  mv -fv "$1" "/Volumes/Public/Shared Videos/Movies"
elif [ "$5" = "tv" ]; then
  mv -fv "$1" "/Volumes/Public/Shared Videos/TV"
fi
it works, but the files don't get copied to the correct location: This is what Sabnzb tells me after the script is completed:

/Volumes/Public/Shared Videos/TV/Futurama/Season 6 -> /Volumes/Public/Shared Videos/TV/Season 6

So it first moves the files to the correct location but then continues to move them around? Why? oO


On My NAS 2 Folders are created in the folder TV: Futurama ( which is empty) and Season 6 ( with the episode file in it)


2


I am running Sabnzb on my Macbook and download files where ever I am. When I am at Home, where my NAS is I would like to have a script that then automatically copies all the new downloaded files to the NAS.
Would I do this with a script/automator action or what? I appreciate any advice on this topic.

Thanks in advance for your help.
th3joker
Jr. Member
Jr. Member
Posts: 64
Joined: January 25th, 2008, 8:15 am

Re: [OSX] Moving Files after downloads

Post by th3joker »

You need to escape the spaces in the directory names:

Code: Select all

#!/bin/bash
if [ "$5" = "movies" ]; then
  mv -fv "$1" "/Volumes/Public/Shared\ Videos/Movies"
elif [ "$5" = "tv" ]; then
  mv -fv "$1" "/Volumes/Public/Shared\ Videos/TV"
fi
So where there's a space between Shared and Videos then immediately after Shared insert "\" and then the space :-)

I changed the script above for you, is there a reason you need to -f (force) the move? and is the -v (verbose) option passing the output somewhere?
Post Reply