Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Delete all .processed files

Reply
 
Old 05-05-2009   #1 (permalink)
Stacey


 
 

Delete all .processed files

First I am not a programmer. I have done a little scripting.

Here is the problem:


Ha a program that creates log files Audit1.log, audit2.log ect. in c:\logs
.. Another program comes along and reads the file into its database and
renames the file audit1.log.proccessed.

I have tried to write a script that will delete any files with .processed
but it will not work. I belive the problem is that it reads from left to
right and sees the .log only.

Any ideas?

Thank you

My System SpecsSystem Spec
Old 05-05-2009   #2 (permalink)
Stacey


 
 

RE: Delete all .processed files

Okay 20 minutes after this post a programmer stopped by.


sub recurse( byref folders)

Set regEx = New RegExp
regEx.Pattern = "\.processed$"
regEx.IgnoreCase = True


set files = folders.files
wscript.echo ""
wscript.echo "Deleting Files under the Folder:" & folders.path
wscript.echo
"__________________________________________________________________________"
for each file in files

if regex.test(file.name) and file.datelastmodified < newdate then
wscript.echo "Deleting " & folders.path & "\" & file.name & " last
modified: " & file.datelastmodified
on error resume next
file.delete
end if

next


It worked.


"Stacey" wrote:
Quote:

> First I am not a programmer. I have done a little scripting.
>
> Here is the problem:
>
>
> Ha a program that creates log files Audit1.log, audit2.log ect. in c:\logs
> . Another program comes along and reads the file into its database and
> renames the file audit1.log.proccessed.
>
> I have tried to write a script that will delete any files with .processed
> but it will not work. I belive the problem is that it reads from left to
> right and sees the .log only.
>
> Any ideas?
>
> Thank you
My System SpecsSystem Spec
Old 05-05-2009   #3 (permalink)
billious


 
 

Re: Delete all .processed files

Crikey!

Perhaps if a real programmer had stopped by, they'd have suggested

DEL /s *.processed

from the command-prompt.

But real programmers are becoming rare nowadays.


"Stacey" <Stacey@xxxxxx> wrote in message
news:315CED02-16C5-4ED8-BCD5-B4574A533E87@xxxxxx
Quote:

> Okay 20 minutes after this post a programmer stopped by.
>
>
> sub recurse( byref folders)
>
> Set regEx = New RegExp
> regEx.Pattern = "\.processed$"
> regEx.IgnoreCase = True
>
>
> set files = folders.files
> wscript.echo ""
> wscript.echo "Deleting Files under the Folder:" & folders.path
> wscript.echo
> "__________________________________________________________________________"
> for each file in files
>
> if regex.test(file.name) and file.datelastmodified < newdate then
> wscript.echo "Deleting " & folders.path & "\" & file.name & " last
> modified: " & file.datelastmodified
> on error resume next
> file.delete
> end if
>
> next
>
>
> It worked.
>
>
> "Stacey" wrote:
>
Quote:

>> First I am not a programmer. I have done a little scripting.
>>
>> Here is the problem:
>>
>>
>> Ha a program that creates log files Audit1.log, audit2.log ect. in
>> c:\logs
>> . Another program comes along and reads the file into its database and
>> renames the file audit1.log.proccessed.
>>
>> I have tried to write a script that will delete any files with .processed
>> but it will not work. I belive the problem is that it reads from left to
>> right and sees the .log only.
>>
>> Any ideas?
>>
>> Thank you

My System SpecsSystem Spec
Old 05-05-2009   #4 (permalink)
Al Dunbar


 
 

Re: Delete all .processed files


"billious" <billious_1954@xxxxxx> wrote in message
news:4a007510$0$12588$5a62ac22@xxxxxx-qv1-newsreader-01.iinet.net.au...
Quote:

> Crikey!
>
> Perhaps if a real programmer had stopped by, they'd have suggested
>
> DEL /s *.processed
>
> from the command-prompt.
>
> But real programmers are becoming rare nowadays.
I disagree. A *REAL* programmer would have obfuscated the code even more!

A *REAL* scripter would have been more likely to come up with the simple
solution.

/Al
Quote:

> "Stacey" <Stacey@xxxxxx> wrote in message
> news:315CED02-16C5-4ED8-BCD5-B4574A533E87@xxxxxx
Quote:

>> Okay 20 minutes after this post a programmer stopped by.
>>
>>
>> sub recurse( byref folders)
>>
>> Set regEx = New RegExp
>> regEx.Pattern = "\.processed$"
>> regEx.IgnoreCase = True
>>
>>
>> set files = folders.files
>> wscript.echo ""
>> wscript.echo "Deleting Files under the Folder:" & folders.path
>> wscript.echo
>> "__________________________________________________________________________"
>> for each file in files
>>
>> if regex.test(file.name) and file.datelastmodified < newdate then
>> wscript.echo "Deleting " & folders.path & "\" & file.name & " last
>> modified: " & file.datelastmodified
>> on error resume next
>> file.delete
>> end if
>>
>> next
>>
>>
>> It worked.
>>
>>
>> "Stacey" wrote:
>>
Quote:

>>> First I am not a programmer. I have done a little scripting.
>>>
>>> Here is the problem:
>>>
>>>
>>> Ha a program that creates log files Audit1.log, audit2.log ect. in
>>> c:\logs
>>> . Another program comes along and reads the file into its database and
>>> renames the file audit1.log.proccessed.
>>>
>>> I have tried to write a script that will delete any files with
>>> .processed
>>> but it will not work. I belive the problem is that it reads from left to
>>> right and sees the .log only.
>>>
>>> Any ideas?
>>>
>>> Thank you
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Solved Why cant I delete certain files General Discussion
unable to delete Names of files after deleted files. Vista mail
Possible to Read only Selected lines from multiple files into anotherfile deleting source files when processed? PowerShell
cant delete files or rename files Vista security
What files keep & what files delete after upgrade ? Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46