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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:50:41+00:00 2026-06-01T00:50:41+00:00

There is a folder which contains some random files: file1.txt file2.exe file3.cpp file4.exe How

  • 0

There is a folder which contains some random files:

file1.txt
file2.exe
file3.cpp
file4.exe

How to SIMPLY display exe files connected with numbers like this:

1. file2.exe
2. file4.exe

And then I enter the number of the file, which I want to delete.. If it is even possible to do this simply..

  • 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-01T00:50:42+00:00Added an answer on June 1, 2026 at 12:50 am

    Shortest bullet proof solution I can come up with. Like Anders, the DEL statement is disabled by the ECHO command. Remove the ECHO to make the menu functional.

    @echo off
    setlocal disableDelayedExpansion
    for /f "delims==" %%A in ('set menu 2^>nul') do set "%%A="
    for /f "tokens=1* delims=:" %%A in ('dir /b *.exe 2^>nul ^| findstr /n "^"') do (
      set menu%%A=%%B
      echo %%A. %%B
    )
    if not defined menu1 exit /b
    set "delNum="
    set /p "delNum=Delete which file (enter the number): "
    setlocal enableDelayedExpansion
    if defined menu!delNum! echo del "!menu%delNum%!"
    

    The only thing I can think of that could go wrong is part of the menu could scroll off the screen if there are too many entries.

    Additional messages can easily be incorporated. and an ELSE condition could be appended to the input validation to deal with invalid input.

    A few subtle points of the code:

    • FINDSTR /N provides incrementing file number. Avoids need for delayed expansion or CALL within menu builder loop. Delayed expansion should not be enabled when expanding a FOR variable containing a file name because it will corrupt names containing !.
    • : is a safe FOR delimiter because a file name cannot contain :.
    • delNum is cleared prior to SET /P because SET /P will preserve existing value if <Enter> is pressed without entering anything.
    • Checking for the existence of the variable is the simplest way to validate the input. This is why it is critical that any existing MENU variables are undefined prior to building the menu.
    • Must use delayed expansion in IF DEFINED validation, otherwise space in input could crash the script (thanks Anders for pointing out the flaw in the original code)
    • DEL target must be quoted in case it contains spaces, even when delayed expansion is used.
    • Added test to make sure at least one menu entry exists before continuing. There may not be any .exe files left to delete.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder A which contains some Python files and __init__.py. If I
My folder contains several files, which are compiled in this order: global.ml , zone.ml
I have a folder which contains some subversion revision checkouts (these are checked out
My django project contains a folder STATIC in which there are it's child folders
I have a folder FolderA which contains three sub-folders: foldera1 foldera2 and foldera3 I
i want to mimic the folder animation. is there an open source library which
Say there is a folder, '/home/user/temp/a40bd22344'. The name is completely random and changes in
I have a folder called Client which contains many subfolders. I want to create
In my application I store on every machine some files in an application folder.
I have an SVN externals folder which contains many folders called *Plugin then within

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.