1.

Solve : Deleting Old files if new files exists?

Answer»

Hi GUYS,
I need an urgent help in solving my problem.

"Every day i get 2 backup files to my directory with different names. I need to delete the old files once it finds new files"

eg: suppose yesterday i have 2 backup files in my directory
c:\1.dat
c:\2.dat

today morning i recieved 2 more files in the same directory.Now i have
c:\1.dat
c:\2.dat
c:\3.dat
c:\4.dat
I need help to write a batch file in DOS to delete the old 2 files if and only if the new files exists.

PLEASE help me in this concern.

Thanks in advance.

chinnadude, you POSTED similar question before. so where's your code?Hi,
I think you should change WAY to write back up file.
write mode append as write mode truncate.

hi ghostdog74,
That code is for searching new files and gives count of files.But i need to delete the old files. I am unable to figure it out (donot know much about DOS)....plz help me...

Thanks in advance,

chinnaHi guys,
please help me to write this code.... its very urgent

chinnaQuote from: chinna on September 15, 2007, 09:42:56 PM

please help me to write this code.... its very urgent

1. EXACTLY why is it "very urgent"? Boss? Teacher?
2. In the other thread you wrote

Quote
Thank you for your hard work and helping me.. Its working perfect

So why not use that code?

hi guys,
Finally i got the solution for this. Here is the code....


echo off
set log=%temp%\filelog.log
forfiles /p c:\test /s /m *.* /d 0 /c " cmd /c echo @file >"%log%" "
if exist "%log%" (
forfiles /p c:\test /s /m *.* /d -1 /c "cmd /c del @file"
)
del %temp%\filelog.log



This code is used to keep the latest files and delete the old files (on date basis).

Thanks for your suggestions..

regards,
chinna


Discussion

No Comment Found