Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:51:45+00:00 2026-06-07T23:51:45+00:00

I have a daily process which generates some zip files out of files that

  • 0

I have a daily process which generates some zip files out of files that are being created by other processes. I need to create a daily log file which indicates the timestamps the contents of one specific file of each zip file that is found.

I created the following batch script which seemed to work yesterday on my test system, but not anymore today, no idea why…

set VersionDirectory=C:\Test\VersionX\
set ResultOutputFile=C:\Test\LogFile.txt

for /f %%f in ('dir /b %VersionDirectory%\Installable\Packages\pattern*.zip') do (
    mkdir %temp%\%%f\
    unzip -extract -dir %VersionDirectory%\Installable\Packages\%%f %temp%\%%f\ > nul
    for %%a in (%temp%\%%f\InstallScript.xml) do set InstallScriptXMLDate=%%~ta
    rmdir /s /q %temp%\%%f\
    echo       %%f [package from %InstallScriptXMLDate%] >> %ResultOutputFile%
)

Short summary of what this file is supposed to do:

  1. Loop through each pattern*.zip file in C:\Test\VersionX\ directory
  2. unzip this file to the %temp%\%%f directory (where %%f is the filename)
  3. Get the timestamp of the %temp%\%%f\InstallScript.xml and put it in the %InstallScriptXMLDate% variable
  4. Delete the %temp%\%%f directory
  5. Echo the filename (%%f) and timestamp (%InstallScriptXMLDate%) into the log file

As of now the log file just contains the filenames, followed by the string ‘[package from ]’ string, but missing the actual date timestamp

The unzipping and removing of the zip files is working flawlessly, it’s just the timestamp that’s not being set.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:51:47+00:00Added an answer on June 7, 2026 at 11:51 pm

    You are setting a variable and using it in the same block. This cannot work in cmd because environment variables are expanded when a statement is parsed not when it’s executed. So when the loop is run all variables have already been replaced with the values they had before the loop.

    Put

    setlocal enabledelayedexpansion
    

    at the start of your batch and use !InstallScriptXmlDate! instead of %InstallScriptXmlDate%.

    Another note: for is perfectly capable of iterating over files by itself, you almost never need to iterate over dir /b output with for /f. In fact, it can introduce problems that can be avoided with

    for %%f in (%VersionDirectory%\Installable\Packages\pattern*.zip)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a process that compiles daily data into an PDF that
I have created a system that sends some information by SMS daily to our
Just as the title goes. I have a python program which processes some data
So we have reports which run, that our client runs multiple times daily and
I have some automated functionality built into my web app that sends email daily
I have a daily cron job that email PDFs to customers. I want to
We have a daily maintenance plan in SQL Server 2005 that performs a full
I have a program running under WPF and MVVM. I have some daily worked
I have this nice little MSBuild-based daily build setup that I use on my
I have a forum where people on a daily basis post links to other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.