Page 1 of 1

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

Posted: August 3rd, 2012, 4:34 pm
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

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

Posted: August 5th, 2012, 2:37 am
by shypike

Code: Select all

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