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 53251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:02:03+00:00 2026-05-10T17:02:03+00:00

I am working on a build system. The build system posts the results as

  • 0

I am working on a build system. The build system posts the results as a zip file in a directory. Unfortunately I have no easy way to know the name of the zip file, because it is timestamped. For the next operation, I must decompress this zip file to some specific location and then do some more file operations.

I guess I could change the build system so I specify the name of the result zip file from the command line, however, I though it might be easiest just to find out which one is the newest file and unzip it (if the previous process is successful).

How can I issue an unzip command that will only take effect on the newest zip file in the directory, ignoring all others?

EDIT: I decided to use the capabilities in ANT for this task instead. However, it is still a neat trick to have up the sleve… Thanks for the answer!

  • 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. 2026-05-10T17:02:03+00:00Added an answer on May 10, 2026 at 5:02 pm

    This should do it:

    FOR /F usebackq %%i IN (`DIR /B /O-D *.ZIP`) DO UNZIP %%i && GOTO DONE || GOTO DONE :DONE 

    This works as follows:

    • DIR /B /O-D *.ZIP lists all ZIP files in reverse date order in a ‘bare’ – i.e. name only – format.
    • FOR /F usebackq is used to loop over the output of the command.
    • && GOTO DONE || GOTO DONE makes sure the UNZIP is only run for the first file. You need both && (and) and || (or) in case the unzip fails for some reason.

    You’ll need to change UNZIP %%i for whatever unzip command you want to use.

    EDIT The above will work as long as the Zip filename doesn’t contain any spaces. If you want to handle filenames with spaces, use the following variant:

    FOR /F 'tokens=*' %%i IN ('DIR /B /O-D *.ZIP') DO UNZIP '%%i' && GOTO DONE || GOTO DONE :DONE 

    The differences are:

    • The ‘tokens=*’ option returns the whole of the filename even if it contains spaces.

    • The filename passed to UNZIP is quoted

    • This variant uses single quotes for the DIR command so doesn’t need the ‘usebackq’ option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working on a comprehensive build system that performs distributed builds on multiple
I am trying to build a working encrypted signature for the Amazon S3 web
I'm working on porting a Visual C++ application to GCC (should build on MingW
I'm working on an iphone application (not web app) and I'd like to build
I'm trying to automate the build of the project I'm working on. My ultimate
Possible Duplicate: Use SVN Revision to label build in CCNET I'm working through the
I'm having a problem with a administrative app I'm working on. I'm build an
I have a working makefile that builds with mingw32. Now i renamed that makefile
I am working on a project that is built on an extended version of

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.