C:\_G\WWW\~ELISANET\INFO\tscmd007.html
<https://www.salminet.fi/info/tscmd007.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Fri 12-Oct-2018 02:38:04

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

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.



7} How can I test if two files agree in size and datetime stamp?

This one is rather simple given the features of XP CMD.EXE.
  @echo off
  ::
  setlocal
  :: Get the filenames (one way or the other)
  set file1_=%~1
  set file2_=%~2
  rem set file1_=c:\_d\bas\batfaq2.bat
  rem set file2_=c:\_f\xtools\xptd.cmd
  ::
  :: Check for existence
  for %%f in ("%file1_%" "%file2_%") do (
    if not exist %%f (
      echo File %%f not found
      goto :EOF))
  ::
  :: Get the filesizes and the datestamps
  for %%f in ("%file1_%") do set size1_=%%~zf
  for %%f in ("%file2_%") do set size2_=%%~zf
  for %%f in ("%file1_%") do set date1_=%%~tf
  for %%f in ("%file2_%") do set date2_=%%~tf
  ::
  :: Also get the full file names (optional)
  for %%f in ("%file1_%") do set file1_=%%~ff
  for %%f in ("%file2_%") do set file2_=%%~ff
  ::
  :: Demonstrate what we've got so far
  echo %date1_% "%file1_%" %size1_%
  echo %date2_% "%file2_%" %size2_%
  ::
  :: Do the comparison
  set same_=false
  if "%size1_%"=="%size2_%" if "%date1_%"=="%date2_%" set same_=true
  ::
  :: Display the results

  if /i "%same_%"=="true" (
    echo The file dates and sizes agree
    ) else (
    echo The file dates and/or sizes do not agree)
  endlocal
  goto :EOF

The output might be e.g.
  C:\_D\TEST>cmdfaq "KOE 2.CMD" "VBSFAQ2.VBS"
  12.09.2004 09:28 "C:\_D\TEST\KOE 2.CMD" 817
  06.10.2007 09:28 "C:\_D\TEST\VBSFAQ2.VBS" 4084
  The file dates and/or sizes do not agree

Also see Item #62.

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd007.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd007
https://www.salminet.fi/info/tscmd007.html
file:///c:/_g/www/~elisanet/info/tscmd007.html