Hi,

I'm looking for a script that:
deletes *.xxx files that are older then Y days.
I have seen a couple of scripts that delete 'old' files in a specific
folder, but my script should only delete a very specific extention in a
specific folder + all subfolders.
Example:It should be capable of deleting all *.ver files located in c:\test
\ and all subfolders, only if they are older then 14 days.

I'm not familiar with VBscript, but I still want to use it, because it
could be modified very easily when using constants in the beginning for the
folder and the extention.

Any idea?
(xxcopy could do similar things, but this doesn't seem to work on my PC,
I'd like to try vbscript)


Thanks!

Sandra.

Re: delete 'old' *.XXX files by Jim

Jim
Sun Feb 20 20:51:29 CST 2005

The easy way would be to click on Start, click on Search
for Files, the set up the parameters you'd like to search
for. It'll find all the files for you, you can then do a CTRL+A,
SHIFT+DELETE to delete all the files that fit... no
scripting necessary. Other than that you can configure a
batch file to do the same thing.

--
Jim Carlock
Post replies to newsgroup.

"Sandra" <antispam@nospam.com> wrote in message news:Xns9603E4EBE1EC8antispamnospamcom@195.130.132.70...
Hi,

I'm looking for a script that:
deletes *.xxx files that are older then Y days.
I have seen a couple of scripts that delete 'old' files in a specific
folder, but my script should only delete a very specific extention in a
specific folder + all subfolders.
Example:It should be capable of deleting all *.ver files located in c:\test
\ and all subfolders, only if they are older then 14 days.

I'm not familiar with VBscript, but I still want to use it, because it
could be modified very easily when using constants in the beginning for the
folder and the extention.

Any idea?
(xxcopy could do similar things, but this doesn't seem to work on my PC,
I'd like to try vbscript)


Thanks!

Sandra.



Re: delete 'old' *.XXX files by Sandra

Sandra
Mon Feb 21 11:55:58 CST 2005

"Jim Carlock" <anonymous@localhost.com> wrote in
news:uJTMz$7FFHA.3824@TK2MSFTNGP10.phx.gbl:

> The easy way would be to click on Start, click on Search
> for Files, the set up the parameters you'd like to search
> for. It'll find all the files for you, you can then do a CTRL+A,
> SHIFT+DELETE to delete all the files that fit... no
> scripting necessary. Other than that you can configure a
> batch file to do the same thing.
>
> --
> Jim Carlock
> Post replies to newsgroup.
>
> "Sandra" <antispam@nospam.com> wrote in message
> news:Xns9603E4EBE1EC8antispamnospamcom@195.130.132.70... Hi,
>
> I'm looking for a script that:
> deletes *.xxx files that are older then Y days.
> I have seen a couple of scripts that delete 'old' files in a specific
> folder, but my script should only delete a very specific extention in
> a specific folder + all subfolders.
> Example:It should be capable of deleting all *.ver files located in
> c:\test \ and all subfolders, only if they are older then 14 days.
>
> I'm not familiar with VBscript, but I still want to use it, because it
> could be modified very easily when using constants in the beginning
> for the folder and the extention.
>
> Any idea?
> (xxcopy could do similar things, but this doesn't seem to work on my
> PC, I'd like to try vbscript)
>
>
> Thanks!
>
> Sandra.
>
>
>

Jim,

The reason why I ask this is that I really need scripting to do that!
Any help please?

Sandra

Re: delete 'old' *.XXX files by Torgeir

Torgeir
Mon Feb 21 12:30:28 CST 2005

Sandra wrote:

> Hi,
>
> I'm looking for a script that:
> deletes *.xxx files that are older then Y days.
> I have seen a couple of scripts that delete 'old' files in a specific
> folder, but my script should only delete a very specific extention in a
> specific folder + all subfolders.
> Example:It should be capable of deleting all *.ver files located in c:\test
> \ and all subfolders, only if they are older then 14 days.
Hi

Below is a script doing this (based on a script by Michael Harris that
deletes files that has not been modified in x days old in a specific
folder and optionally all subfolders, original script here:
http://groups.google.co.uk/groups?selm=3DA1A19B.DF9B06D7%40hydro.com
)


'--------------------8<----------------------
'If bIncludeSubFolders is set to True, it will include subfolders

' folder to start search in...
path = "c:\temp"

' delete files with this extension...
killextension = "ver"

' delete files older than 14 days...
killdate = date() - 14

arFiles = Array()
set fso = createobject("scripting.filesystemobject")

' Don't do the delete while you still are looping through a
' file collection returned from the File System Object (FSO).
' The collection may get mixed up.
' Create an array of the file objects to avoid this.
'
SelectFiles path, killdate, arFiles, true

nDeleted = 0
for n = 0 to ubound(arFiles)
'=================================================
' Files deleted via FSO methods do *NOT* go to the recycle bin!!!
'=================================================
on error resume next 'in case of 'in use' files...
arFiles(n).delete true
if err.number <> 0 then
wscript.echo "Unable to delete: " & arFiles(n).path
else
nDeleted = nDeleted + 1
end if
on error goto 0
next

msgbox nDeleted & " of " & ubound(arFiles)+1 _
& " eligible files were deleted"


sub SelectFiles(sPath,vKillDate,arFilesToKill,bIncludeSubFolders)
on error resume next
'select files to delete and add to array...
'
set folder = fso.getfolder(sPath)
set files = folder.files

for each file in files
' uses error trapping around access to the
' Date property just to be safe
'
dtlastmodified = null
on error resume next
dtlastmodified = file.datelastmodified
on error goto 0
if not isnull(dtlastmodified) then
if dtlastmodified < vKillDate and _
lcase(fso.getextensionname(file)) = lcase(killExtension) Then

count = ubound(arFilesToKill) + 1
redim preserve arFilesToKill(count)
set arFilesToKill(count) = file
end if
end if
next

if bIncludeSubFolders then
for each fldr in folder.subfolders
SelectFiles fldr.path,vKillDate,arFilesToKill,true
next
end if
end sub


'--------------------8<----------------------

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: delete 'old' *.XXX files by Jim

Jim
Mon Feb 21 12:50:13 CST 2005

Sandra,

Try this and see if this helps... http://tinyurl.com/5huye

--
Jim Carlock
Post replies to newsgroup.

"Sandra" wrote:
> Jim,
>
> The reason why I ask this is that I really need scripting to do
> that! Any help please?
>
> Sandra