deleting files older than...


M

Markus Mannheim

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
 
Ad

Advertisements

M

Michael Bednarek

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 /[[email protected]%_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.
 
T

Timo Salmi

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
 
G

Guest

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
 
D

David Candy

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.
 
Ad

Advertisements

K

Kok Yong Lee

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
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.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top