WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Newbie ..... is this possible
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1097592743

Message started by njb on Oct 12th, 2004 at 10:52pm

Title: Newbie ..... is this possible
Post by njb on Oct 12th, 2004 at 10:52pm
using Watchdirectory, is it possible to delete files that have not been modified for a duration of days ( i.e delete all files that have not been modified in the previuos 180 days ).

Thanks

Title: Re: Newbie ..... is this possible
Post by Gert on Oct 12th, 2004 at 11:19pm
Hello "njb",

Sorry, but watchDirectory reacts to events that HAPPEN inside a directory. What you are after is something that didn't happen (no updates in 180 days)...

Your specific example (delete after 180 days), can almost be handled by our freeware GdPUtil program (http://www.gdps.dk/products/watchDir/GdPUtil.shtml):

GdPUtil -deleteolderthan 180 c:\temp

will delete all files that were created more than 180 days ago.
If you ask very politely, I will add an option for this to work  with the modification date.

Gert

Title: Re: Newbie ..... is this possible
Post by njb on Oct 13th, 2004 at 6:43pm
Gert ... this is me asking very nicely     ;D

Title: Re: Newbie ..... is this possible
Post by Gert on Oct 13th, 2004 at 11:36pm
okay, a new version is uploaded.
I didn't change the webpage yet, but you should use -modifiedolderthan instead of -deleteolderthan.

note, some filesystems do not support this modification date (Last Write date), I am not sure what will happen if you run it on such filesystems.

Gert

Title: Re: Newbie ..... is this possible
Post by njb on Oct 14th, 2004 at 5:30pm
Thanks GERT, new version downloaded, I will test and let you know if I have any issues.

Nigel

Title: Re: Newbie ..... is this possible
Post by jesper on Oct 17th, 2004 at 3:45am
This is very useful, thanks.

Could it be modified to take hours or even minutes as argument instead of days? :-)

And could it work across subdirs? Useful for cleaning
out old logfiles for example.

On top of this, it would be nice to add a -test, which would just echo the files that _would_ have been deleted.

Similar to tmpwatch:
http://linux.maruhn.com/sec/tmpwatch.html

Title: Re: Newbie ..... is this possible
Post by Gert on Oct 17th, 2004 at 7:29am
Hej Jesper!

Det er godt 'ideas' (my danish is getting really bad these days, sorry).

Anyway, those are good ideas, expect an update soon.....

mvh,
Gert

Title: Re: Newbie ..... is this possible
Post by jesper on Oct 17th, 2004 at 3:31pm
Hej

Reading through the archives i was hoping for a positive and swift response, and once again you impress! I will be looking forward to the update, thank you :-)

Jeg er i tvivl om det danske islæt, med .dk domæne og danskklingende navn Gert, så er det jo nærliggende at tro i er et dansk firma. (Well better keep it english for the rest of the audience)!



Title: Re: Newbie ..... is this possible
Post by Gert on Oct 17th, 2004 at 4:57pm
Jesper,

I used to live in Silkeborg for about 1 year. The problem was: my girlfriend and kids all spoke english so there was no pressing reason to learn Danish.

Anyway, I have uploaded version 1.8 of GdPUtil a few minutes ago.


Quote:
 -deleteolderthan days directory [filemask] [-force] [-subdirs] [-test] [-hours]
     Deletes all files in <directory> that are created more than <days> days ago
     filemask: only for files matching this mask, for example *.log
           (if no filemask is specified, *.* is used)
     -force: reset read-only attribute before trying to delete
     -subdirs: also remove files from subdirectories
     -test: do not delete files, just report the files that would be deleted
     -hours: interpret "days" as hours instead
     Example:
       GdPUtil -deleteolderthan 14 c:\temp *.log -subdirs
       will delete all log-files older than 14 days from C:\Temp and below
 -modifiedolderthan days directory [filemask] [-force] [-subdirs] [-test] [-hours]
     see -deleteolderthan. Uses the Last Write time of the file, instead of the creation date.

Title: Re: Newbie ..... is this possible
Post by jesper on Oct 17th, 2004 at 5:15pm
:-)

Thank you very much, testing it now!


Title: Re: Newbie ..... is this possible
Post by jesper on Oct 17th, 2004 at 5:50pm
Works perfect, and fast too!

I have missed that default behaviour does not remove empty dirs, for example after all the files are removed, leaving a lot of empty dirs behind.

Can you add a -dirs for "Also remove empty directories"?

Or change default behaviour then adding this:
      -d, --nodirs
             Do not attempt to remove directories, even if they are empty.
From tmpwatch manpage:
http://www.freebsd.org/cgi/man.cgi?query=tmpwatch&apropos=0&sektion=0&manpath=FreeBSD+5.2.1-RELEASE+and+Ports&format=html

Just another suggestion :-)

Title: Re: Newbie ..... is this possible
Post by Gert on Oct 17th, 2004 at 6:22pm
... and I thought to have a nice and quiet sunday morning...
Okay, uploaded a new version. Use "-removeempty" for this.

It will only work properly for leaf directories. Directories that have subdirectories (even if those subdirectories are deleted by this switch) won't be removed.

However, you can run GdPUtil a few times in a row using the same switches.

Gert

Title: Re: Newbie ..... is this possible
Post by jesper on Oct 17th, 2004 at 7:06pm
... and as expected, it works, thank you Gert!

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