I am trying to create symlinks for multiple directories/files some of which have spaces in the name. The purpose is to keep a clean library, while allowing rtorrent to continue seeding. Thus, I have a watch folder and my library folder and I want to create symlinks in the library folder from the completed files in the watch folder. Here is the script I am using now:
Code: Select all
findcommand=”find /mnt/Media/Music/.watch –maxdepth 1 –not –iname “*.torrent””
for item in ‘$findcommand’;
ln –s $item /mnt/Media/Music/;
This works great for files without spaces in the name; however, for files with spaces in the name, it creates a link for each word.
.../Music/.watch has folders:
/Rush, /Credence Clearwater Revival, and /Jim.Croce
Running the scripts yields:
.../Music/Link to Rush, /Link to Credence, /Link to Clearwater, /Link to Revival, and /Link to Jim.Croce
Obviously the /Credence, /Clearwater, and /Revival links don't work because those directories don't exist.
So, I ask: what am I doing wrong/how can I fix this?
As a follow up, is there a way I could automate this, either by scheduling the script to run on a timer/at a set time, or by having it check for a state change in the folder and adding a symlink each time a torrent is completed (i.e. a new folder/file is added to the .watch directory)?
Thanks in advance.