This page is edited from the 1cmdfaq.txt faq-file contained in
my tscmd.zip
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
companion.
Please see "
The Description and
the Index page" for the conditions of usage and other such
information.
98} How do I equate all zip files with the date of their latest file?
A typical archive maintainer's task.
@echo off & setlocal enableextensions
rem
rem Covert a zip file datestamp to equal the datestamp of the
rem most recent file within the zip archive. Traverses all the
rem zip files in the default folder.
rem
rem Needs zip.exe from
rem 355508 Oct 19 2008 zip300xn.zip
rem zip300xn.zip Info-ZIP command-line zip for Win9x/NT/2K/XP/2K3
rem or more generally http://garbo.uwasa.fi/win95/arcers.html
rem
rem Uses the switch "-o" to "make zipfile as old as latest entry"
rem
rem By Prof. Timo Salmi
rem Last modified Sun 27-Dec-2009
::
set ziprog=
C:\_F\FTOOLS\ZIP.EXE
:: The zip-program needs the local Time Zone information
set tz_=%TZ%
set TZ=Europe/Helsinki
:: Check that there are zip files to be processed
if not exist "*.zip" goto _nofile
:: Do the timestamping
for %%f in ("*.zip") do
"%ziprog%" -o %%f
:: Show the results
dir "*.zip" | find /i ".ZIP"
:: Restore the original Time Zone variable in case it had a different value
set TZ=%tz_%
goto _out
::
:_nofile
echo No .zip files found to process
goto _out
::
:_out
endlocal & goto :EOF
Before running the script we might have
27.12.2009 20:07 21,678 test.zip
27.12.2009 19:46 1,178,993 XPAD_.ZIP
The output could be e.g.
C:\_D\TEST>C:\_D\TOOLS\ZIPOTS.CMD
16.10.2009 12:41 21,678 test.zip
07.12.2009 07:33 1,178,993 XPAD_.ZIP
If, instead of the Info-ZIP zip program you have the
command-line
module for
Winzip,
substitute
set ziprog=C:\Program Files\WinZip\WZZIP.EXE
if defined ProgramW6432 set ziprog=C:\Program Files (x86)\WinZip\WZZIP.EXE
and
for %%f in ("*.zip") do "%ziprog%" -o %%f -x"*.*"
If you are using the
7-Zip file
archiver, onto a single .7z file apply (and so on for multiple files)
set ziprog=C:\Program Files\7-Zip\7z.exe
"%ziprog%" d -stl "C:\_M\SevenTest.7z" nul