troubleshooting Question

BATCH SCRIPT HELP - Compress, Move, delete and increment

Avatar of Richiep86
Richiep86 asked on
Windows Batch
6 Comments1 Solution956 ViewsLast Modified:
HI All,

I have the following BAT script:

@echo off

REM Define file and folder locations
set BaseDir=c:\TestFiles
set DestZip=c:\OldLogs\
set z=c:\program files\7-zip\7z.exe

REM Zip all files and folders
"%z%" a -tzip "%DestZip%" -r "%BaseDir%\*.*"

This script grabs the contents of C:\TestFiles, compresses all the files and stores it in c:\OldLogs\ This is perfect, although i need the script to now:

1) Delete the old files from C:\TestFile where older than x days
2) The needs to increment each time the script is run, a time stamp would be ideal here:


and so on...

Many thanks,
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros