forfiles used with echo modifiying date modified?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

forfiles used with echo modifiying date modified?

#1 Post by SIMMS7400 » 19 Dec 2020 10:53

Hi Folks -

I'm trying to use forfiles logic to echo the content that meets the specified criteria which I want to leverage in a logfile. I then want to have a second forfiles setup to actually delete that content. However, the first forfiles seems to be changing the date modified. Is there a way to get around that?

Code: Select all

	FOR /F "tokens=*" %%a IN (
		'FORFILES /P "!STRING!" /S /D -!AGE! /C "cmd /c IF @ISDIR == TRUE ECHO @path"^
			2^>^&1 ^| FINDSTR /I ERROR'
	) DO SET "CMDRSLTECHO=%%a"

Code: Select all

	FOR /F "tokens=*" %%a IN (
		'FORFILES /P "!STRING!" /S /D -!AGE! /C "cmd /c IF @ISDIR == TRUE RD /S /Q @path"^
			2^>^&1 ^| FINDSTR /I ERROR'
	) DO SET "CMDRSLT=%%a"
Thanks!

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: forfiles used with echo modifiying date modified?

#2 Post by SIMMS7400 » 01 Jan 2021 04:54

Hi folks, is there another way to go about this to meet my need? Thanks!

Post Reply