Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Zipping files (DOS Batch) (Win 3.1 and on)

    To celebrate the renaming of the Windows CE forum to Windows Mobile, I wrote a new DOS Batch file (grin!)
    I'm rather pleased.
    As usual, I drag copies of the installation files to a folder ..Deploy.
    I open a DOS window, load CED (or DOSKEY) and navigate to ..Deploy.

    I check the time on the system clock!

    Once it has rolled past the minute (e.g. seconds read 20 past the minute) I type "ZipArch" and watch it run.
    ZipArch produces a Log file ZIPARCH.log which is, of course, not embedded within the Zip file so ...
    I up-arrow and rerun ZipArch within the same minute.

    Result: A Zipped archive, named with today's date/time (hence unique) AND contains a documented listing of files with the correct date/time stamps all over!
    Attached Files Attached Files

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts

    Re: Zipping files (DOS Batch) (Win 3.1 and on)

    If this runs only on XP or above, it could be simplified by about a factor of 3-5!

    I've always found it to be a Good Idea to try and make a BATch file completely self-contained, referring only to programs built-in to Windows and not to any other BATch file - saves losing odd bits.

    Your Kilometerage May Vary!
    BATcher

    Time prevents everything happening all at once...

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Zipping files (DOS Batch) (Win 3.1 and on)

    Batcher, thanks for the comments.
    I mainly wanted to brag about getting the LOG file into the ZIP file with the correct date/time stamp.


    >If this runs only on XP or above, it could be simplified by about a factor of 3-5!
    Absolutely. My batch files go back before 1985, as do many of yours, I'm sure.
    You can see that I converted the SetDate but not the SetTime (one of these days .......).

    >make a BATch file completely self-contained,
    This would be nice, but I rely heavily on the date/time fields in many batch files to establish unique names.
    I suspect that means that a better design of DOS would have been to make the year, month, day, hour, minute, seconds, weekday, am/pm values avaiable as native values, but the window of opportunity for implementing this is probably gone (grin!0

  4. #4
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,417
    Thanks
    33
    Thanked 195 Times in 175 Posts

    Re: Zipping files (DOS Batch) (Win 3.1 and on)

    The answer may be to use one of Ritchie Lawrence's Date and/or Time functions (see the BATch function library), or use what I call my embedded Universal Date and Time Routine...<pre>:: generalised DATE and TIME routine for NT4/W2K/WXP/W2K3 and all Regional Settings
    :: %yy% will contain four digits, 20nn;
    :: %mm%, %dd% and time variables %hr%, %mn%, %sc% and %th% contain two digits
    if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
    for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo.^|date') do (
    for /f "tokens=%toks% delims=.-/ " %%e in ('date /t') do (
    for /f "tokens=5-8 delims=:., " %%i in ('echo.^|time') do (
    (set %%a=%%e) & (set %%b=%%f) & (set %%c=%%g) & rem create yy, mm, dd
    (set hr=%%i) & (set mn=%%j) & (set sc=%%k) & (set th=%%l)
    rem note the variable names for Time: hr, mn, sc, th
    )))
    if 1%yy% LSS 200 (set yy=20%yy%) & :: ensure 4-digit years in %yy%
    if 1%hr% LSS 20 (set hr=0%hr%) & :: ensure 2-digit hours in %hr%

    echo Date is: %yy%-%mm%-%dd% Time is: %hr%:%mn%:%sc%.%th%</pre>

    Select only part if you need just date or time.
    BATcher

    Time prevents everything happening all at once...

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Zipping files (DOS Batch) (Win 3.1 and on)

    THANKS!


    Whoever knew?<pre>The if statement has a lot of functionality. Common uses include the following.
    if /i <string1> <compare> <string2> <command> The /i parameter makes the comparison case-insensitive.
    The comparison can be one of the following.
    EQU—equal
    NEQ—not equal
    LSS—less than
    LEQ—less than or equal
    GTR—greater than
    GEQ—greater than or equa</pre>


  6. #6
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Zipping files (DOS Batch) (Win 3.1 and on)

    And here's a 2nd set of thanks -- for both the routine and the link. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •