Delete files smaller than XXMB
-
- Newbie
- Posts: 14
- Joined: July 6th, 2012, 4:50 am
Delete files smaller than XXMB
I've searched the forum but couldn't find a script that does this.
I'm looking for a python script to delete files smaller than xxMB after extracting.
This way all the ''junk'' is removed when i download tvshows and movies.
( i know you can auto delete files by file extension in the SAB menu but this is not enough )
Thank you for your help!!
I'm looking for a python script to delete files smaller than xxMB after extracting.
This way all the ''junk'' is removed when i download tvshows and movies.
( i know you can auto delete files by file extension in the SAB menu but this is not enough )
Thank you for your help!!
Re: Delete files smaller than XXMB
If (as?) such a Python script is not here, are you willing to write it yourself? Python is a great language, and it will only take a few lines of code.
-
- Newbie
- Posts: 14
- Joined: July 6th, 2012, 4:50 am
Re: Delete files smaller than XXMB
I have tried to put something together but it did not work. I have no scripting knowledge what so ever,
So all help is appreciated !!
So all help is appreciated !!
Re: Delete files smaller than XXMB
Can you post what you've put together yourself?solonvault wrote:I have tried to put something together but it did not work. I have no scripting knowledge what so ever,
So all help is appreciated !!
Re: Delete files smaller than XXMB
find -size -500k -exec rm {\}\ \;
maybe ?
maybe ?
Re: Delete files smaller than XXMB
Is that correct syntax? I changed the rm to ls, and that doesn't work:exussum wrote:find -size -500k -exec rm {\}\ \;
maybe ?
Code: Select all
sander@toverdoos:~$ find -size -500k -exec ls {\}\ \ ;
find: missing argument to `-exec'
sander@toverdoos:~$
Code: Select all
find . -type f -size -500k -exec ls -al {} \;
Re: Delete files smaller than XXMB
I remember having to escape more, I should learn to try commands before posting
Your way is better than mine - Looking for files too (mine could pick up directory's / links)
Your way is better than mine - Looking for files too (mine could pick up directory's / links)
Re: Delete files smaller than XXMB
Well, thanks for hint towards 'find'.exussum wrote:I remember having to escape more, I should learn to try commands before posting
Your way is better than mine - Looking for files too (mine could pick up directory's / links)
I seldom use 'find'; I usually "clay" together a one-liner of ls/sed/awk/ etc. Maybe I should use 'find' more.
BTW: in case "claying together" is not correct English: it is Dutch for putting something together in a not too beautiful way.
-
- Newbie
- Posts: 14
- Joined: July 6th, 2012, 4:50 am
Re: Delete files smaller than XXMB
Thanks guys!
So the complete code is
put this in a .py file
This will delete files smaller than 0,5mb .
Is this correct ?
And will the script only delete files in the ''extract folder'' or all folders ?
Thank you for your reply!
So the complete code is
Code: Select all
#!/usr/bin/env python
find . -type f -size -500k -exec ls -al {} \;
This will delete files smaller than 0,5mb .
Is this correct ?
And will the script only delete files in the ''extract folder'' or all folders ?
Thank you for your reply!
Re: Delete files smaller than XXMB
Well, it is a shell script, not a python script. A shell script runs on Linux / Unix / OSX.
Because you have not yet replied to my question "Can you post what you've put together yourself?", we still don't know which OS you're using ...
Because you have not yet replied to my question "Can you post what you've put together yourself?", we still don't know which OS you're using ...
Re: Delete files smaller than XXMB
also you would have to change the -exec ls -al to -exec rm the first just details the deleted files, the second actually deletes them
edit: a windows version here
http://stackoverflow.com/questions/6764 ... cific-size
or install find from
http://unxutils.sourceforge.net/
and it should work
edit: a windows version here
http://stackoverflow.com/questions/6764 ... cific-size
or install find from
http://unxutils.sourceforge.net/
and it should work
-
- Newbie
- Posts: 14
- Joined: July 6th, 2012, 4:50 am
Re: Delete files smaller than XXMB
im using a Qnap NAS with a other python script working ( prowl ).
i have tried similar script, but thought it where python scripts :-s
do i just put the script
in a .sh file and it will work ?
And will the script only delete files in the ''extract folder'' or all folders ?
Thanks again for your help!
i have tried similar script, but thought it where python scripts :-s
do i just put the script
Code: Select all
find . -type f -size -500k -exec ls -al {} \;
And will the script only delete files in the ''extract folder'' or all folders ?
Thanks again for your help!
-
- Newbie
- Posts: 14
- Joined: July 6th, 2012, 4:50 am
Re: Delete files smaller than XXMB
Anyone?? i would think this shouldn't have to be that hard to answer for someone who knows what he's doing..
Thanks!
Thanks!
Re: Delete files smaller than XXMB
solonvault wrote:Anyone?? i would think this shouldn't have to be that hard to answer for someone who knows what he's doing..
Thanks!
instead of ls -al use rm
and yes it should work
Re: Delete files smaller than XXMB
My advice to you:solonvault wrote:Anyone?? i would think this shouldn't have to be that hard to answer for someone who knows what he's doing..
Thanks!
Just execute the command from the command line of your NAS, and see what is does. Try to understand it.
FYI: the command is harmless: with the "ls" (and no "rm") it just list files and directories. It does not delete anything.
As soon as you understand the one-liner, change it the way you like it, and then put it in a script, and only then into SABnzbd.