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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:06:33+00:00 2026-06-05T15:06:33+00:00

is there a way with windows command line to list all the files from

  • 0

is there a way with windows command line to list all the files from a specific directory and then select the name of the file that has the newest creation date.

Thank you

  • 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-05T15:06:34+00:00Added an answer on June 5, 2026 at 3:06 pm

    This iterates through a directory listing and sets an environment variable to each file in order by date; the last one set would be the newest file:

    for /F "delims=" %%I in ('dir /b /a-d /od') do set LATEST=%%I
    echo "%LATEST%"
    

    Then you could copy the file like so:

    copy "%LATEST%" destination
    

    Based on the solution found here.

    EDIT: I also got the %%I was unexpected at this time error when executing this directly through the command prompt, but it worked fine from within a batch file. You could create a batch file with the above and it should work.

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

Sidebar

Related Questions

Is there way to get file from windows xp command prompt? I tried to
Is there a way to hide the windows command prompt or prevent it from
Is there any way of launching Windows Explorer from ant without stopping the build?
Is there a way to know the Default Installation Directory of XCode through command
Is there a way to simulate the *nix tail command on the Windows command
I'm looking for a way to figure out the command-line arguments of any Windows
I'm using the following line to update a directory via the Windows/DOS command line:
Is there a (Linux or Windows) command line tool that is able to create
I'm running a few different windows command scripts that all reference the same directory.
I have a command line which copies files from folder A to folder B:

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.