WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> How to:  Delete plugin
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1329140641

Message started by mkanet on Feb 13th, 2012 at 2:44pm

Title: How to:  Delete plugin
Post by mkanet on Feb 13th, 2012 at 2:44pm
Hi Gert, I would like for the "Delete Files" plugin to ONLY delete empty relative directories if no folders that end with .tmp are detected.

It sounds very simple, but I can't figure out how to do this. :(

Below is the WD task I created; hoping WD would stop processing any further events IF it sees a folder with .tmp extension.  However, this does not work.  I have tried multiple combinations; but all failed.



PS:  This watch directory "Delete Files" task also deletes any files with specific extensions.  I would prefer to limit all of this to only WatchDirectory task if at all possible.
Thanks, as always!
Michael

Title: Re: How to:  Delete plugin
Post by Gert on Feb 14th, 2012 at 8:40am

Quote:
It sounds very simple

And you got me confused ;-)

Are you trying to
delete *.nfo files that are NOT in *.tmp directories
remove empty *.tmp directories

because I think that's what the filters say....

Perhaps you can give some examples using full paths telling which file/dir should be removed so I can understand better.


Title: Re: How to:  Delete plugin
Post by mkanet on Feb 14th, 2012 at 2:59pm
Hi Gert, not that's not at all what I want to do.  I want to delete any empty folders ONLY IF folders with the name *.tmp don't exist.  I also want to delete other types of files with various extensions; but, it's not necessary to do it in the same WD task.

Scan folder E:\Downloads

If the folder "E:\Downloads\empty_folder" is empty delete it

If there there exists a folder called "E:\Downloads\temp_zip_Rar_folder.tmp" and there is a empty folder called "E:\Downloads\empty_folder" do NOT delete it until "E:\Downloads\temp_zip_Rar_folder.tmp" is gone.

Title: Re: How to:  Delete plugin
Post by Gert on Feb 14th, 2012 at 3:08pm
So basically....

If there is ANY folder named "*.tmp" inside the monitored folder, for example those folders would qualify
C:\Mon\SomeSub.tmp\Anothersubfolder
c:\Mon\hello\SomeSub.tmp
Then no folders (tmp or otherwise) should EVER be deleted.


Title: Re: How to:  Delete plugin
Post by mkanet on Feb 14th, 2012 at 3:09pm
Yes, no empty folders should "ever be deleted" UNTIL "c:\Mon\hello\SomeSub.tmp" is gone.

Title: Re: How to:  Delete plugin
Post by Gert on Feb 14th, 2012 at 3:18pm
OK,

For that you will need the "Run a bat file" task.
Set it to File Age method, poll every XX seconds (for example every minute), do NOT enable "remember triggered files"
Only select the DIRNEW event.

The script will be something like this:
[code]
rem check if there is a tmp folder somewhere below the monitored directory
DIR /s /ad "%WD_DIR%\*.tmp"
if %errorlevel% EQU 0 GOTO :EOF

rem no tmp directory found, try to remove the directory which triggered us
rem if it gives an error, ignore it. Most likely the directory is not empty
RD "%WD_FILE%"
[/code]

Not tested but it should work.

Title: Re: How to:  Delete plugin
Post by mkanet on Feb 14th, 2012 at 3:31pm
Thanks I will try it!!!

Title: Re: How to:  Delete plugin
Post by Gert on Feb 14th, 2012 at 4:45pm
Do not make things confusing by talking about yet another task.

Nothing can be done "immediately", there will always be a delay. Do I understand the 60 seconds (the interval I suggested for this task) is too much? So how much is ok?

Title: Re: How to:  Delete plugin
Post by mkanet on Feb 14th, 2012 at 5:14pm
Yes, I would much prefer for it to happen immediately (around 1 second).  The only reason I mentioned another task is because they both need the same condition (do not execute if *.tmp folders present).    

The other WD task executes a batch file as soon as an audio/video file is created or deleted.  Unlike the original task, this one DOES have to happen immediately after a *.tmp folder disappears.

Wouldn't it better to add a condition to the WD "delete file(s)" and "execute batch file" plugins to not execute if a file or folder exists?  This would be much easier for the user and much more efficient in processing the action immediately.


Gert wrote on Feb 14th, 2012 at 4:45pm:
Do not make things confusing by talking about yet another task.

Nothing can be done "immediately", there will always be a delay. Do I understand the 60 seconds (the interval I suggested for this task) is too much? So how much is ok?


Title: Re: How to:  Delete plugin
Post by Gert on Feb 14th, 2012 at 5:22pm
Yes that would be much easier for "the user", provided that you are the only user because adding this option would potentially add confusion for everyone else.

I will need to think about this.

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.