PC Review


Reply
Thread Tools Rate Thread

deleting files older than...

 
 
Markus Mannheim
Guest
Posts: n/a
 
      26th Sep 2005
Hi,

on an ftp Server I am running a script which clears all files in subfolders
of the users:

:: Variablen
set datei=d:\scripte\folders.txt
set start=d:\ftp
set start2=ftp

setlocal
d:
cd\
cd %start2%
dir /a:d /b >%datei%
FOR /F %%G IN (%datei%) DO (
cd %%G
pushd %start%\%%G%
cd\
cd %start2%\%%G%
for /F "tokens=1-3,* delims=\" %%A in ('dir /B /S /AD^|sort /R') do (
if "" NEQ "%%D" RD /Q /S "%%A\%%B\%%C\%%D")
del %start%\%%G%\*.* /q /f
copy d:\scripte\readme.txt ./y

d:
cd\
cd %start2%
popd)
del %datei%
set start=
set start2=

Now this script deletes all files whenever I run it via "Sheduled Tasks".
Because our users are working in different countries, the files should
remain for 24 hours, instead.
Some of you may have an idea how to read the date of a file and compare it
with the actual date?

For help thanks in advance,

Markus


 
Reply With Quote
 
 
 
 
Michael Bednarek
Guest
Posts: n/a
 
      26th Sep 2005
On Mon, 26 Sep 2005 10:08:24 +0200, "Markus Mannheim"
<(E-Mail Removed)> wrote in
microsoft.public.win2000.cmdprompt.admin:

>on an ftp Server I am running a script which clears all files in subfolders
>of the users:
>
>:: Variablen
>set datei=d:\scripte\folders.txt
>set start=d:\ftp
>set start2=ftp

[snip]
>Now this script deletes all files whenever I run it via "Sheduled Tasks".
>Because our users are working in different countries, the files should
>remain for 24 hours, instead.
>Some of you may have an idea how to read the date of a file and compare it
>with the actual date?


Trivial with the right CLI, 4NT in this case:
DEL /[d-1@%_time,1980/1/1] /S /X /Y d:\ftp\*.*
This will delete files older than yesterday at the time when the script
runs; IOW: if it's now 26-Sep-2005 19:24 it will delete files modified
on or before 25-Sep-2005 19:24. It will also remove all empty
directories.

4NT's Date Ranges are documented at
<http://jpsoft.com/help/dateranges.htm>. 4NT's DEL command is documented
at <http://jpsoft.com/help/del.htm>. 4NT is a commercial product.

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
      26th Sep 2005
Markus Mannheim wrote:
(snip)

45} How can I find out how many days old a file is?
60} How do I delete all but most recent 20 files in a folder?
136348 Sep 25 13:47 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
private.php?do=newpm&u= <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
 
Reply With Quote
 
=?Utf-8?B?bWV0YWZpemlr?=
Guest
Posts: n/a
 
      7th Dec 2005
Hi Marcus,

We use a freeware utility called decay to purge files on one of the FTP
servers where I work. It might be the tool you are looking for. I can't
promise but it won't cost you anything to give it a shot. It can be found
here: http://www.linkdata.se/software.html

"Markus Mannheim" wrote:

> Hi,
>
> on an ftp Server I am running a script which clears all files in subfolders
> of the users:
>
> :: Variablen
> set datei=d:\scripte\folders.txt
> set start=d:\ftp
> set start2=ftp
>
> setlocal
> d:
> cd\
> cd %start2%
> dir /a:d /b >%datei%
> FOR /F %%G IN (%datei%) DO (
> cd %%G
> pushd %start%\%%G%
> cd\
> cd %start2%\%%G%
> for /F "tokens=1-3,* delims=\" %%A in ('dir /B /S /AD^|sort /R') do (
> if "" NEQ "%%D" RD /Q /S "%%A\%%B\%%C\%%D")
> del %start%\%%G%\*.* /q /f
> copy d:\scripte\readme.txt ./y
>
> d:
> cd\
> cd %start2%
> popd)
> del %datei%
> set start=
> set start2=
>
> Now this script deletes all files whenever I run it via "Sheduled Tasks".
> Because our users are working in different countries, the files should
> remain for 24 hours, instead.
> Some of you may have an idea how to read the date of a file and compare it
> with the actual date?
>
> For help thanks in advance,
>
> Markus
>
>
>

 
Reply With Quote
 
David Candy
Guest
Posts: n/a
 
      7th Dec 2005
What's wrong with disk cleanup. It does 7 days by default if doing the temp but can be changed to do other folders.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\CustomDeleter]
@="{C0E13E61-0CC6-11d1-BBB6-0060978B2AE6}"
"FileList"="*.fred"
"Folder"=hex(2):63,00,3a,00,5c,00,64,00,65,00,73,00,6b,00,74,00,6f,00,70,00,00,\
00
"Flags"=dword:00000000
"LastAccess"=dword:00000002
"StateFlags"=dword:00000001
"Display"="Custom"
"Description"="Clears a custom folder"


Here's one I just made that does *.fred in c:\desktop if more than 2 days since last accessed.
Merge the file then look here in the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\CustomDeleter
and alter the path and filetype. Also as the path is an Expand type it's in hex in the regfile and in english in the reg (because regfiles don't support expand so it uses hex). If using environmental variables the data type must be expand.


To use
cleanmgr /sageset:<a number>
and only tick the Customer Deleter
This sets it up

Then to run or schedule
cleanmgr /sagerun:<same number used above>

You can have as many pairs of sageset/run as you want.



--
--------------------------------------------------------------------------------------------------
Goodbye Web Diary
http://margokingston.typepad.com/har....html#comments
=================================================
"metafizik" <(E-Mail Removed)> wrote in message news:A9EFCB25-7E87-41EA-AF0B-(E-Mail Removed)...
> Hi Marcus,
>
> We use a freeware utility called decay to purge files on one of the FTP
> servers where I work. It might be the tool you are looking for. I can't
> promise but it won't cost you anything to give it a shot. It can be found
> here: http://www.linkdata.se/software.html
>
> "Markus Mannheim" wrote:
>
>> Hi,
>>
>> on an ftp Server I am running a script which clears all files in subfolders
>> of the users:
>>
>> :: Variablen
>> set datei=d:\scripte\folders.txt
>> set start=d:\ftp
>> set start2=ftp
>>
>> setlocal
>> d:
>> cd\
>> cd %start2%
>> dir /a:d /b >%datei%
>> FOR /F %%G IN (%datei%) DO (
>> cd %%G
>> pushd %start%\%%G%
>> cd\
>> cd %start2%\%%G%
>> for /F "tokens=1-3,* delims=\" %%A in ('dir /B /S /AD^|sort /R') do (
>> if "" NEQ "%%D" RD /Q /S "%%A\%%B\%%C\%%D")
>> del %start%\%%G%\*.* /q /f
>> copy d:\scripte\readme.txt ./y
>>
>> d:
>> cd\
>> cd %start2%
>> popd)
>> del %datei%
>> set start=
>> set start2=
>>
>> Now this script deletes all files whenever I run it via "Sheduled Tasks".
>> Because our users are working in different countries, the files should
>> remain for 24 hours, instead.
>> Some of you may have an idea how to read the date of a file and compare it
>> with the actual date?
>>
>> For help thanks in advance,
>>
>> Markus
>>
>>
>>

 
Reply With Quote
 
Kok Yong Lee
Guest
Posts: n/a
 
      3rd Jan 2006
Hi David,

Just wondered is it possible to instruct cleanmgr to delete files older
thatn m days rather than based on last accessed?

thanks.



"David Candy" <.> wrote in message
news:e4o57Q1%(E-Mail Removed)...
What's wrong with disk cleanup. It does 7 days by default if doing the temp
but can be changed to do other folders.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\CustomDeleter]
@="{C0E13E61-0CC6-11d1-BBB6-0060978B2AE6}"
"FileList"="*.fred"
"Folder"=hex(2):63,00,3a,00,5c,00,64,00,65,00,73,00,6b,00,74,00,6f,00,70,00,00,\
00
"Flags"=dword:00000000
"LastAccess"=dword:00000002
"StateFlags"=dword:00000001
"Display"="Custom"
"Description"="Clears a custom folder"


Here's one I just made that does *.fred in c:\desktop if more than 2 days
since last accessed.
Merge the file then look here in the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\CustomDeleter
and alter the path and filetype. Also as the path is an Expand type it's in
hex in the regfile and in english in the reg (because regfiles don't support
expand so it uses hex). If using environmental variables the data type must
be expand.


To use
cleanmgr /sageset:<a number>
and only tick the Customer Deleter
This sets it up

Then to run or schedule
cleanmgr /sagerun:<same number used above>

You can have as many pairs of sageset/run as you want.



--
--------------------------------------------------------------------------------------------------
Goodbye Web Diary
http://margokingston.typepad.com/har....html#comments
=================================================
"metafizik" <(E-Mail Removed)> wrote in message
news:A9EFCB25-7E87-41EA-AF0B-(E-Mail Removed)...
> Hi Marcus,
>
> We use a freeware utility called decay to purge files on one of the FTP
> servers where I work. It might be the tool you are looking for. I can't
> promise but it won't cost you anything to give it a shot. It can be found
> here: http://www.linkdata.se/software.html
>
> "Markus Mannheim" wrote:
>
>> Hi,
>>
>> on an ftp Server I am running a script which clears all files in
>> subfolders
>> of the users:
>>
>> :: Variablen
>> set datei=d:\scripte\folders.txt
>> set start=d:\ftp
>> set start2=ftp
>>
>> setlocal
>> d:
>> cd\
>> cd %start2%
>> dir /a:d /b >%datei%
>> FOR /F %%G IN (%datei%) DO (
>> cd %%G
>> pushd %start%\%%G%
>> cd\
>> cd %start2%\%%G%
>> for /F "tokens=1-3,* delims=\" %%A in ('dir /B /S /AD^|sort /R') do (
>> if "" NEQ "%%D" RD /Q /S "%%A\%%B\%%C\%%D")
>> del %start%\%%G%\*.* /q /f
>> copy d:\scripte\readme.txt ./y
>>
>> d:
>> cd\
>> cd %start2%
>> popd)
>> del %datei%
>> set start=
>> set start2=
>>
>> Now this script deletes all files whenever I run it via "Sheduled Tasks".
>> Because our users are working in different countries, the files should
>> remain for 24 hours, instead.
>> Some of you may have an idea how to read the date of a file and compare
>> it
>> with the actual date?
>>
>> For help thanks in advance,
>>
>> Markus
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Deleting records older than a year Graham Mandeno Microsoft Access VBA Modules 8 13th May 2009 09:26 PM
Re: Deleting records older than a year Graham Mandeno Microsoft Access VBA Modules 0 12th May 2009 09:58 PM
How can I get Outlook (2002) from deleting emails older than 6 day =?Utf-8?B?TWFyayBIaWxicmluaw==?= Microsoft Outlook 2 15th Jul 2007 07:40 PM
How do I keep Outlook from automatically deleting older events? =?Utf-8?B?QW5keSBU?= Microsoft Outlook Calendar 1 30th Oct 2006 06:00 PM
Deleting older calendar months Nancy Microsoft Outlook Calendar 1 7th Nov 2003 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:06 AM.