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

  • Home
  • SEARCH
  • 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 48891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:21:04+00:00 2026-05-10T16:21:04+00:00

I have up to 4 files based on this structure (note the prefixes are

  • 0

I have up to 4 files based on this structure (note the prefixes are dates)

  • 0830filename.txt
  • 0907filename.txt
  • 0914filename.txt
  • 0921filename.txt

I want to open the the most recent one (0921filename.txt). how can i do this in a batch file?

Thanks.

  • 1 1 Answer
  • 3 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-10T16:21:04+00:00Added an answer on May 10, 2026 at 4:21 pm

    This method uses the actual file modification date, to figure out which one is the latest file:

    @echo off for /F %%i in ('dir /B /O:-D *.txt') do (     call :open '%%i'     exit /B 0 ) :open     start 'dummy' '%~1' exit /B 0 

    This method, however, chooses the last file in alphabetic order (or the first one, in reverse-alphabetic order), so if the filenames are consistent – it will work:

    @echo off for /F %%i in ('dir /B *.txt^|sort /R') do (     call :open '%%i'     exit /B 0 ) :open     start 'dummy' '%~1' exit /B 0 

    You actually have to choose which method is better for you.

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

Sidebar

Related Questions

This question is based on the thread . If we have one-to-many data structure,
I have a PHP script that creates other PHP files based on user input.
I have the following code to create a music playlist based on files in
We have a sharepoint based application that uses a custom database for storing metadata/files
I have a txt file with columns separated by tabs and based on that
I have a Struts based web application that has a structure similar to the
Possible Duplicate: Git - Whitelisting files in a complex directory structure I have a
I have an app (cms) which structure is like this: BASE: /application/ /public/ themes/
I have simple web application based on JSP. Root of application looks like this:
We're building a Windows-based application that traverses a directory structure recursively, looking for files

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.