Page 1 of 2
[Windows] Download Dir Cleaner
Posted: July 15th, 2008, 4:07 pm
by eagle00789
The code below cleans the download dir from the following files: nzb, sfv, url and db
Code: Select all
@echo off
setlocal
set fcount=0
set nzbcount=0
set sfvcount=0
set urlcount=0
set dbcount=0
echo.
echo [Cleanup] Cleaning up download directory: %1
echo [Cleanup] Deleteing .nzb files
for /f %%V in ('dir %1*.nzb /b /s ^2^>NUL ^| find /v /c ""') do set/a nzbcount = %%V
if %nzbcount% GTR 0 del /s /q "%1"*.nzb > NUL 2>NUL
echo [Cleanup] Deleteing .sfv files
for /f %%V in ('dir %1*.sfv /b /s ^2^>NUL ^| find /v /c ""') do set/a sfvcount = %%V
if %sfvcount% GTR 0 del /s /q "%1"*.sfv > NUL 2>NUL
echo [Cleanup] Deleteing .url files
for /f %%V in ('dir %1*.url /b /s ^2^>NUL ^| find /v /c ""') do set/a urlcount = %%V
if %urlcount% GTR 0 del /s /q "%1"*.url > NUL 2>NUL
echo [Cleanup] Deleteing .db files
for /f %%V in ('dir %1*.db /b /s ^2^>NUL ^| find /v /c ""') do set/a dbcount = %%V
if %dbcount% GTR 0 del /s /q "%1"*.db > NUL 2>NUL
set/a fcount = %nzbcount% + %sfvcount% + %urlcount% + %dbcount%
echo [Cleanup] Deleted %fcount% files (%nzbcount% nzb, %sfvcount% sfv, %urlcount% url, %dbcount% db)
echo.
Re: [Windows] Download Dir Cleaner
Posted: July 23rd, 2008, 11:40 am
by eagle00789
Small update to the script to make the output a bit more cleaner then before. Before, if a file was not found (like nzb for example) in the complete dir, then an error would show up saying "File not found". this version has that error removed (With help from EE)
Re: [Windows] Download Dir Cleaner
Posted: July 24th, 2008, 12:02 pm
by DeXeS
Nice!
Does this script run a cleanup before or after the parring and unpacking?
Re: [Windows] Download Dir Cleaner
Posted: July 24th, 2008, 3:35 pm
by eagle00789
pair of dimes wrote:
DeXeS wrote:
Nice!
Does this script run a cleanup before or after the parring and unpacking?
I'm sure after, as that is when all post-processing scripts are executed.
Indeed After the parring, unpacking and moving to the download-dir
Re: [Windows] Download Dir Cleaner
Posted: August 22nd, 2008, 8:59 pm
by EvilSIN
thnx for the script
Re: [Windows] Download Dir Cleaner
Posted: August 24th, 2008, 3:32 pm
by deepblue
Hi Guys,
I'm trying to get this to work on 0.4.2 (Win32), and Sabnzbd is running it, but it doesn't appear to be removing the files. Here's the output:
---------------------
SABnzbd has downloaded 'XXXX'.
Finished at 2008-08-24 15:51:06
Downloaded 366.4 MB
Results of the job:
Stage Download
[Avg-Speed] 1371kB/s
[Time-Taken] 4 minutes 33 seconds
Stage Par2
[PAR-INFO] XXXXX => Verified in 19.1s, all files correct
[DEL-INFO] XXXXX => Deleted 3 file(s)
Stage Unrar
[DEL-INFO] XXXXX=> Deleted 25 file(s)
[RAR-INFO] XXXXX => Unpacked 1 file(s) in 23.8s
Stage UserScript
[USER-SCRIPT] => Running user script E:\NZB\SAB\scripts\cleanup.cmd
External processing by E:\NZB\SAB\scripts\cleanup.cmd:
[Cleanup] Cleaning up download directory: "E:\XBMC\Video\TV\XXXXX"
[Cleanup] Deleteing .nzb files
[Cleanup] Deleteing .sfv files
[Cleanup] Deleteing .url files
[Cleanup] Deleteing .db files
[Cleanup] Deleted 0 files (0 nzb, 0 sfv, 0 url, 0 db)
---------------------
I've checked the folder it is referencing, and there is a .nzb and .sfv file still sitting there. Any ideas? Can I adjust this to remove .nfo files just by tweaking the extensions in the code?
Thanks.
Re: [Windows] Download Dir Cleaner
Posted: August 24th, 2008, 4:27 pm
by cydine
Seems to be missing a couple vital backslashes.
Here's a slightly modded version that works for me. Removes nfo, nzb, sfv, idx, sub.
Code: Select all
@echo off
setlocal
set fcount=0
set nzbcount=0
set sfvcount=0
set nfocount=0
set subcount=0
set idxcount=0
echo.
echo [Cleanup] Cleaning up download directory: %1
echo [Cleanup] Deleting .nzb files
for /f %%V in ('dir %1\*.nzb /b /s ^2^>NUL ^| find /v /c ""') do set/a nzbcount = %%V
if %nzbcount% GTR 0 del /s /q %1\*.nzb > NUL 2>NUL
echo [Cleanup] Deleting .sfv files
for /f %%V in ('dir %1\*.sfv /b /s ^2^>NUL ^| find /v /c ""') do set/a sfvcount = %%V
if %sfvcount% GTR 0 del /s /q %1\*.sfv > NUL 2>NUL
echo [Cleanup] Deleting .nfo files
for /f %%V in ('dir %1\*.nfo /b /s ^2^>NUL ^| find /v /c ""') do set/a nfocount = %%V
if %nfocount% GTR 0 del /s /q %1\*.nfo > NUL 2>NUL
echo [Cleanup] Deleting .sub files
for /f %%V in ('dir %1\*.sub /b /s ^2^>NUL ^| find /v /c ""') do set/a subcount = %%V
if %subcount% GTR 0 del /s /q %1\*.sub > NUL 2>NUL
echo [Cleanup] Deleting .idx files
for /f %%V in ('dir %1\*.idx /b /s ^2^>NUL ^| find /v /c ""') do set/a idxcount = %%V
if %idxcount% GTR 0 del /s /q %1\*.idx > NUL 2>NUL
set/a fcount = %nzbcount% + %sfvcount% + %nfocount% + %subcount% + %idxcount%
echo [Cleanup] Deleted %fcount% files (%nfocount% nfo, %nzbcount% nzb, %sfvcount% sfv, %subcount% sub, %idxcount% idx)
echo.
Re: [Windows] Download Dir Cleaner
Posted: September 11th, 2008, 2:45 pm
by eagle00789
here is the updated version without the NFO file deletion as some downloads have some valuable info in the nfo-file...
Code: Select all
@echo off
setlocal
set fcount=0
set nzbcount=0
set sfvcount=0
set subcount=0
set idxcount=0
set urlcount=0
set dbcount=0
echo.
echo [Cleanup] Cleaning up download directory: %1
echo [Cleanup] Deleting .nzb files
for /f %%V in ('dir %1\*.nzb /b /s ^2^>NUL ^| find /v /c ""') do set/a nzbcount = %%V
if %nzbcount% GTR 0 del /s /q %1\*.nzb > NUL 2>NUL
echo [Cleanup] Deleting .sfv files
for /f %%V in ('dir %1\*.sfv /b /s ^2^>NUL ^| find /v /c ""') do set/a sfvcount = %%V
if %sfvcount% GTR 0 del /s /q %1\*.sfv > NUL 2>NUL
echo [Cleanup] Deleting .sub files
for /f %%V in ('dir %1\*.sub /b /s ^2^>NUL ^| find /v /c ""') do set/a subcount = %%V
if %subcount% GTR 0 del /s /q %1\*.sub > NUL 2>NUL
echo [Cleanup] Deleting .idx files
for /f %%V in ('dir %1\*.idx /b /s ^2^>NUL ^| find /v /c ""') do set/a idxcount = %%V
if %idxcount% GTR 0 del /s /q %1\*.idx > NUL 2>NUL
echo [Cleanup] Deleting .url files
for /f %%V in ('dir %1\*.url /b /s ^2^>NUL ^| find /v /c ""') do set/a urlcount = %%V
if %urlcount% GTR 0 del /s /q %1\*.url > NUL 2>NUL
echo [Cleanup] Deleting .db files
for /f %%V in ('dir %1\*.idx /b /s ^2^>NUL ^| find /v /c ""') do set/a dbcount = %%V
if %dbcount% GTR 0 del /s /q %1\*.idx > NUL 2>NUL
set/a fcount = %nzbcount% + %sfvcount% + %subcount% + %idxcount% + %urlcount% + %dbcount%
echo [Cleanup] Deleted %fcount% files (%nzbcount% nzb, %sfvcount% sfv, %subcount% sub, %idxcount% idx, %urlcount% url, %dbcount% db)
echo.
Re: [Windows] Download Dir Cleaner
Posted: October 27th, 2008, 5:47 pm
by Waldorfz
Stupid question for you guys. I'm new to SABnzbd so I'm still trying to figure a few things out. I realize that post processing scripts run after the job in unpacked but do they still run if the job fails? I'd like to use a script like this to cleanup my tv downloads. Right now it will downloasd them and move them to a specific directory based on shaw name and season. I'd like to get rid of all the junk (.nzb, .nfo .par2) but not if it fails. I've had a job fail that I was able to manually repair with quickpar that the built in par2 did not fix. If I delete all the .par2 files after a job fails than I'm kinda stuck and can't repair it. I'd have to manually download these files again. Any advice?
Re: [Windows] Download Dir Cleaner
Posted: October 27th, 2008, 9:21 pm
by Waldorfz
Apparently my PAR2 issue is a setup problem due to a UNC path to the incomplete directory according to the new 4.5 RC. I'm still curious to know if the script will run if something before it fails though for future reference. I can't seem to find anything on that. Thanx.
Re: [Windows] Download Dir Cleaner
Posted: October 28th, 2008, 4:13 am
by shypike
but do they still run if the job fails
There's an option "Safe Postprocessing" (Config->Switches) which determines whether scripts re run on a failed job.
Later releases will have an extra parameter telling you what the result was.
Re: [Windows] Download Dir Cleaner
Posted: February 22nd, 2009, 9:14 am
by Coeluh
Again, how do I install this?
Re: [Windows] Download Dir Cleaner
Posted: March 1st, 2009, 8:29 am
by Coeluh
What extensions does it require? It just opens a .txt now, and does nothing....
Re: [Windows] Download Dir Cleaner
Posted: October 22nd, 2009, 2:50 am
by Coeluh
I put it in a file and named it cleanup.cmd, but I cant select it in SABnzbd, how can I help this?
Re: [Windows] Download Dir Cleaner
Posted: October 29th, 2009, 9:40 pm
by feerlessleadr
this is sort of in line with my other thread in this forum.
Is there anyway to modify this script so that it will only delete the most recent file instead of all the files.
for example it will only delete the most newly created nfo in the folder?