devoinr1970
asked on
Creating script that will zip file every 15 days
I'm creating a script which will zip all doc files in 1 directory, which are 15 days old. I'm using winzip64, but for some reason I cannot get the script to zip the files. Also, after the files have been zip for 45 days I want to delete the zipped files. below is my script, but I have not added the date checks. I would like help creating the date check and finding out why this code will not zip the files.
@echo off
if exist "c:\Users\Devoin\testfolder\*.doc*" (
echo. File Exists
C:\Program Files\WINZIP64 -a c:\Users\Devoin\TestSSIS\DataFiles_20130903.zip c:\Users\Devoin\testfolder\*.doc
REM xcopy c:\Users\Devoin\testfolder\*.doc* c:\Users\Devoin\TestSSIS
REM del c:\Users\Devoin\testfolder\*.doc*
REM pause
REM exit
) else (
echo Random Text >>"c:\Users\Devoin\testfolder\*.doc*"
REM exit
)
goto :EOF
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you can use a third party utility, the easiest way to clean up the old files could be DELAGE32, take a look at it at:
http://www.horstmuc.de/wbat32.htm
http://www.horstmuc.de/win/delage.htm
If not then we could use FORFILES in the BAT script to do it (which you might already have on Windows if it's recent). or could even do it with pure DOS BAT command, but that is a bit more complicated - BAT not great as date math.
~bp
http://www.horstmuc.de/wbat32.htm
http://www.horstmuc.de/win/delage.htm
If not then we could use FORFILES in the BAT script to do it (which you might already have on Windows if it's recent). or could even do it with pure DOS BAT command, but that is a bit more complicated - BAT not great as date math.
~bp
> ...for some reason I cannot get the script to zip the files.
Check C:\Program Files\WINZIP64
Is that the correct .exe name?
Check C:\Program Files\WINZIP64
Is that the correct .exe name?
If WinZip is installed with defaults it would be:
"%ProgramFiles%\WinZip\win zip64"
"%ProgramFiles%\WinZip\win
Why wouldn't we be using the WZZIP command line tool for WinZip (free) from a batch script, rather than the UI version of the program (WINZIP64.EXE)? I never do that...
~bp
~bp
The following worked for me:
Note that cmd has a problem with "program files" and gets confused about the first and second argument, so I reverted back to the dos naming scheme.
C:\Users\sm> forfiles /p C:\Users\sm\Documents\Correspondence /s /d -15 /m *.doc* /c "cmd /c C:\Progra~1\WinZip\wzzip.exe -a C:\Users\sm\Documents\Correspondence\stor.zip @path"
Note that cmd has a problem with "program files" and gets confused about the first and second argument, so I reverted back to the dos naming scheme.
ASKER
Thank you very much for your help. This worked greated
Open in new window
and this to delete the old onesOpen in new window