MSDOS Batch File Question!

  • Thread starter Thread starter Maxwell2006
  • Start date Start date
M

Maxwell2006

Hi,



I am trying to write a batch file to delete all files older than one hour
within a folder.



Because of some restriction, I cannot use any 3rd party tool to do that.



What would be the most efficient MSDOS batch file to that?



Any help would be appreciated,

Max
 
Maxwell2006 said:
Hi,

I am trying to write a batch file to delete all files older than one hour
within a folder.

Because of some restriction, I cannot use any 3rd party tool to do that.

What would be the most efficient MSDOS batch file to that?

Any help would be appreciated,

Max

Are these files in the one single folder or are they all over the
place?

BTW, MSDOS is an operating system. It got retired many years
ago. I suspect you're talking about the Command Prompt under
Windows XP.
 
Pegasus (MVP) said:
Are these files in the one single folder or are they all over the
place?

BTW, MSDOS is an operating system. It got retired many years
ago. I suspect you're talking about the Command Prompt under
Windows XP.

Hi Pegasus,

These are files in a single folder.

Youu are right. Command Prompt is what i meant.

Thank you,
Max
 
Maxwell2006 said:
Hi Pegasus,

These are files in a single folder.

Youu are right. Command Prompt is what i meant.

Thank you,
Max

You can use this batch file:

Line1 @echo off
Line2 goto Start
Line3 --------------------------------------------------
Line4 This batch file will delete all .txt files that
Line5 existed before the batch file was previously invoked.
Line6
Line7 15.1.2007 FNL
Line8 --------------------------------------------------
Line9 :Start
Line10 set LogFile=%temp%\xcopy.log
Line11 if not exist "%LogFile%" cd 1>0 2>"%LogFile%"
Line12
Line13 for /F "tokens=*" %%* in ('type "%LogFile%"') do echo del "%%*"
Line14 xcopy /a /L /c *.txt C:\Dummy\ | find ":" > "%LogFile%"

Use the Task Scheduler to invoke this batch file once every your.

Line14 will take a snapshot of all files that were added during the
last hour.

Line13 will delete all files listed in the snapshot file.

Remove the word "echo" in Line13 in order to activate the
"del" command.

Use copy & past to create this batch file. Do NOT retype it!
 
Back
Top