Confirm files by date

Does not matter / Does not matter
November 19, 2010 at 11:35:30
Specs: Win Server 2k3
I am working on a batch file to archive files older than a number of days. I'm using the ForFiles command to handle the move/delete operation. I need to add something that will tell me if there are files (and how many) that meet my criteria before actually doing anything to them. I've tried a ForFiles statement for that piece as well, but it's not working. Here's the code...

Set Count=0
Set KeepDays=10
::Count files to be archived
ForFiles /D -%KeepDays% /P C:\EDI\Logs /C "Cmd /c Set /a Count=+1"
Echo FTP log files to be archived = %Count%

The %Count% variable is never incremented. What's up with that?? Is there a better/different way to accomplishe the same thing?

See More: Confirm files by date

Report •

November 19, 2010 at 13:38:55
The official reason why %COUNT% never seems to increase involves environment heredity. Basically, %COUNT% is incremented in a different (temporary) Command Prompt window.


ForFiles /D -%KeepDays% /P C:\EDI\Logs | find /c /v ""

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question