Hello snowman,
Thursday, April 6, 2006, 7:21:38 PM, you wrote:
> I need delete files in c:\temp, but older 7 days. In c:\temp and
> subfolders (unknown name). What this make?
Why do you want to keep temp files for 7 days?
I think it is not necessary. You can safely delete ALL files and folders
in c:\temp\ if you do it just after the computer has finished booting.
It is possible, by a few different methods:
[A] Write a PowerPro script. This will be difficult and complicated.
There is a command *File DeleteOld which allows you to specify
a number of days and the path to a folder (optionally with a
wildcard filename to only delete some files).
Command: File
Action: DeleteOld
Enter days[etc]: 7 "c:\temp"
;; deletes all files in C:\Temp older than 7 days.
File DeleteOld 7 "c:\temp\*.txt"
;; will only delete .txt files in C:\Temp older than 7 days.
If you have temp files in several places, you could write a script:
File DeleteOld 7 "C:\Documents and Settings\username\Local Settings\Temp"
File DeleteOld 7 "C:\Temp"
File DeleteOld 7 "C:\Windows\Temp"
In a script file, you can use the new kind of syntax:
file.deleteold(7,?"c:\temp")
I think File DeleteOld cannot delete files in subfolders.
If subfolder names are not known, or keep changing,
which happens in \temp\, you can use File.Allfiles(...)
to make any command recursive for subfolders.
The script would be roughly like this:
;; First, delete all old files, including in subfolders:
file.allfiles(?"c:\temp",?"File.DeleteOld(7,_file_)",1)
;; That part was easy.
;; Now we have to find the empty folders and delete them.
;; declare some temporary variables:
local listvar linevar
;; now make a list inside listvar,
listvar=File.ListFiles(?"c:\temp",2)
;; some lines in that list are young files which were not deleted,
;; and some are folders. [See file.txt in your plugins folder.]
;; Write a For loop which reads each line one at a time into linevar,
;; then tests if it is a folder, then tests if it is empty:
For(i=1,i<line(listvar,0),i=i+1)
linevar=line(listvar,i)
if((file.isfolder(linevar)) and (not validpath(linevar++?"\*.*"))do
file.delete(linevar)
endif
endfor
Caution: the script syntax in my messages usually contains errors.
Can somebody please check the above?
I think that script will only delete one level of subfolders.
[B] use a specialised utility.
This will be easier than writing a script.
There are many freeware deleters for temp files.
Most of them simply delete all the temp files.
EraseTemp freeware from
http://www.nodesoft.com/EraseTemp/Default.aspx
is the only one I found which allows you to specify
how many days old, in its command line parameters.
[C] use xxcopy from http://www.xxcopy.com/index.htm
This is a Win95/98/ME/NT/2000/XP/2003 utility which runs in
command line mode. It is a very powerful program, with many
parameters which will allow you to do exactly what you want.
It can copy, move, rename, delete files and folders based on
many factors such as date, attributes, etc.
It will take a few days of reading to find out how to use it.
Its best to download all the xxcopy Technical Bulletins in one zip:
http://www.xxcopy.com/download/xxtb2926.zip
as well as reading the website.
[D] do it the easy way.
Delete everything in \temp\ including all subfolders.
If you do it just after booting, it will do no harm.
All temp files from your previous Windows sessions are useless.
You could use the .bat file which David suggested to you
in pp beginners forum, or your own variation of it
with a few lines like this: rd /s /q c:\temp
Attention: PowerPro's Web site has moved: http://www.ppro.org
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/power-pro/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/