I just wrote this simple script to cover my simple needs. What I would like is that the files I download are renamed as the NZB I download. Sabnzbd already puts these downloaded files in a directory named after the NZB.
Currently the situation is like this:
Movies/NZBnameinqueu/a.mkv
b.nfo
c.srt
I would like it to become this:
Movies/NZBnameinqueu/NZBnameinqueu.mkv
NZBnameinqueu.nfo
NZBnameinqueu.srt
Please bear with me as this is the first code I ever wrote (probably cannot get any simpler ). Can the experts tell me if it will do what I would like it to do?
#!/bin/bash
for files in *; do
[ ! -f "$3.${files##*.}" ] && mv -v "$files" "$3.${files##*.}"
done
That will.
Of course if you have multiple files with same extension only the first will be renamed.
Thanks for trying to help me out. Your script worked in an unexpected way. Instead of renaming the downloaded file, it renamed my entire SABnzbd program directory, making the application crash instantly. I was worried 2 seconds hoping my entire file server would not have been renamed. Luckily only did the Sabnzbd directory.