need help on script to delete older sub-folder on qnap

Come up with a useful post-processing script? Share it here!
Post Reply
chaleman
Newbie
Newbie
Posts: 1
Joined: August 3rd, 2012, 4:27 pm

need help on script to delete older sub-folder on qnap

Post by chaleman »

Hi Guys... this is an awesome place...

I have a QNAP 459Pro and I wish to write a post-processing script to delete the folder with the oldest date in a given subfolder. Reason is, I download David Letterman shows and only wish to keep, say the last 5... So my way of thinking (for keeping things simple) is to download the last 5 shows, and then when downloading the 6th one, implement the script... this way, after it finished downloading it, it should erase the oldest folder, thus always keeping just the last 5....

I tried this command:
rm -r $(ls -t -r /share/TV/David_Letterman | head -n 1)

The problem is that the sub-folders within the "David_Letterman" folder contain spaces.. i.e. "David Letterman 2012 07 26 Joel McHale HDTV x264 2HD" and this command can't deal with spaces when trying to delete them...

Can someone please shed some light on how to do this... This would be great!!! Thanks!

Carlos
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: need help on script to delete older sub-folder on qnap

Post by shypike »

Code: Select all

rm -r "$(ls -t -r /share/TV/David_Letterman | head -n 1)"
Post Reply