Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch file - Need an Alternative to 7-zip - cannot move

Please see updated answer below

Windows Batch files.

I absolutely love 7-Zip and works great, but like WinZip's ability to move and timestamp files. However, WinZip's (command-line interface) has limitations for the size of files and the quantity of files within an archive, for example.

Googling we do see that there is a person, who did take 7-zip's code and has re-compiled the code to use an -m (move) switch. However, I don't feel comfortable about using a third-party outside of the Developer of 7-zip in our Production environment.

Also, I have seen - http://alternativeto.net/software/7-zip/

I have coded: IF NOT ERRORLEVEL 1 (after the Zip process) to delete the file, but this cannot be safe if there are multiple of the same file name structure.

Here are some sample bits of code: 7zip:

D:\scripts\7za -tzip -y a D\zips\20140116_someclient_%computername%@%location%.zip D:\logs\apache_log.2014-01-16* >nul >>%logfile%
IF NOT ERRORLEVEL 1 ECHO Y|DEL D:\logs\apache_log.2014-01-16*

Where apache_log.2014-01-16 could be:

apache_log.2014-01-16.1
apache_log.2014-01-16.2
apache_log.2014-01-16.3

etc.

WinZip

c:\progra~1\WinZip\Wzzip.exe -T -ex -m D\zips\20140116_someclient_%computername%@%location%.zip D:\logs\some_file.2014-01-16* >nul >>%logfile%

I guess from a software requirements standpoint, I would like to have some of the abilities of WinZip in 7Zip.. I like 7Zip as it has the ability to work with large Archives. I like PeaZip and I used PowerArchiver many moons ago. Problem I have is that I am working with Apache Tomcat for Windows, and we have to archive off hourly logs that can be over 200-300 MB an hour and need to keep the servers clear of old logs.

Hope this makes more sense.

UPDATE:

Do believe that I have answered my own question..

FOR /F %%F IN ('dir /B "D:\serverlogs\server.log.2014-01-19*"') DO (
D:\work\scripts\7za.exe –tzip –y a "D:\ziplogs\[email protected]" >> D:\WORK\SCRIPTS\LOGS\LOG_20140120.LOG && DEL "D:\serverlogs\%%F"
)

Which this does work well now.

like image 1000
Leptonator Avatar asked Mar 21 '23 22:03

Leptonator


1 Answers

Latest alpha versions of 7-Zip support new switch "-sdel" to delete files after including to archive.

like image 144
Igor Pavlov Avatar answered Mar 31 '23 23:03

Igor Pavlov