Delete files on specific date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Delete files on specific date

#16 Post by ShadowThief » 06 Oct 2014 10:38

I did also have the test vs temp typo, but even after fixing that, I still get no output and the files still exist. Also, if I get rid of echo y|, then I'm prompted to delete the files.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete files on specific date

#17 Post by foxidrive » 06 Oct 2014 10:43

Here's my test: (Virtualbox not VMware)

Image

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete files on specific date

#18 Post by foxidrive » 06 Oct 2014 10:49

You are right.

When I use this then it behaves like yours does:

Code: Select all

@echo off
if a==a echo y|del c:\test\*.*

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete files on specific date

#19 Post by foxidrive » 06 Oct 2014 10:55

This is a workaround for that issue.
It's a new one on me too.

Code: Select all

if not "%date%"=="24-10-2014" goto skip
echo y|del c:\test\*.*
:skip

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Delete files on specific date

#20 Post by ShadowThief » 06 Oct 2014 10:56

The workaround seems to be to use a goto in the if statement to call a subroutine to do the piped deletion.

Code: Select all

if "%date%"=="10-06-2014" goto wipeit
exit

:wipeit
echo y|del C:\temp\*.*

works.

EDIT: Although yours is nicer.

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Delete files on specific date

#21 Post by ShadowThief » 06 Oct 2014 12:17

I wonder if it's related to http://support2.microsoft.com/kb/81089

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: Delete files on specific date

#22 Post by pieh-ejdsch » 06 Oct 2014 13:38

Hallo,
When you use command.com
Eg. From windows 98 I've written a batch for timestamp.

http://www.administrator.de/forum/win98-batch-datum-ermitteln-und-die-variable-splitten-in-tag-mon-jahr-221318.html#comment-891359
Phil

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Delete files on specific date

#23 Post by foxidrive » 06 Oct 2014 16:39

pieh-ejdsch wrote:Hallo,
When you use command.com
Eg. From windows 98 I've written a batch for timestamp.


Is that the 286 line batch script?
It seems very complex



ShadowThief wrote:I wonder if it's related to http://support2.microsoft.com/kb/81089


It may be.

Ubaid
Posts: 4
Joined: 05 Oct 2014 13:35

Re: Delete files on specific date

#24 Post by Ubaid » 10 Oct 2014 05:09

I appreciate to foxidrive and ShadowThief,s support... I did follow the instructions and success to build script Is run fine for me,

Thanks for supports.. :D

Post Reply