Computing.Net > Forums > Programming > batch list files of dir+user choice

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

batch list files of dir+user choice

Reply to Message Icon

Original Message
Name: datec
Date: July 15, 2008 at 16:20:17 Pacific
Subject: batch list files of dir+user choice
OS: 2k/xp
CPU/Ram: 512
Comment:

hey guys,
after you had such a great solution for the first problem, i have now another ;-)

i want the batch to check a specific directory, let's say "c:\files", list all files, that end with *.ppt, and make a choice table. than the user chooses e.g. number 3, and the batch file continues processing with e.g. echo "you have choosen number 3".

anybody an idea how to solve this in a batch?


thx a ton
datec


Report Offensive Message For Removal


Response Number 1
Name: ghostdog
Date: July 15, 2008 at 19:03:53 Pacific
Reply: (edit)

you have a solution for your first problem, whatever it is. So what is stopping you from starting to code for yourself? Have you been learning batch since your first problem?


Report Offensive Follow Up For Removal

Response Number 2
Name: justcallmegreg
Date: July 16, 2008 at 14:08:12 Pacific
Reply: (edit)

Copy and paste this example.

@echo off

:: Change this to any directory, I used windows because it's already on the computer.
cd c:\windows

:: I used all exe's here but you can change that to *.ppt or whatever.
dir *.exe
pause

:: Change the following anyway you see fit.
GOTO :Choices

:Choices
echo 1. Whatever
echo 2. Whatever
echo 3. Whatever
echo.

set /p choice=Please choose a number:
IF NOT '%choice%'=='' set choice=%choice:~0,1%
IF '%choice%'=='1' GOTO choice1
IF '%choice%'=='2' GOTO choice2
IF '%choice%'=='3' GOTO choice3
pause

GOTO :Choices

:choice1
echo You chose 1
pause
exit

:choice2
echo You chose 2
pause
exit

Also google batch file tutorials, there's a lot of info out there.

Good luck,

Greg


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software