Computing.Net > Forums > Programming > Filename as stored variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Filename as stored variable

Reply to Message Icon

Name: dwarner8
Date: October 12, 2009 at 10:01:22 Pacific
OS: Windows XP
Product: Microsoft Windows xp pro w/ sp3 multilingual
Subcategory: Batch
Tags: batch
Comment:

I would like to list all .txt files or any given extention in a specified directory in flat format.

dir *.txt /b

the output would look something like:

something.txt
somethingelse.txt

then I would like to take the filenames and store them as variables.

Next the user would be presented with choices using set command so he can review files.

1. something.txt
2. somethingelse.txt

the script would promt for input

please select a file to compare:

the user selects 1 and the filename gets stored in a variable. The user then selects another number and it also gets stored into a variable.

What I am trying to do is automate a way to compare 2 files.

The user selects what 2 files he wants to compare, then the compare %variable of first file% %variable of second file% > Compare.txt


for %%f in (?) do set filename=%%f



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: October 12, 2009 at 10:33:56 Pacific
Reply:

@echo off & setLocal EnableDELAYedExpansion

set N=
for /f "tokens=* delims= " %%a in ('dir/b *.bat') do (
set /a N+=1
set v!N!=%%a
echo !N! %%a
)
echo.
set /p F=pick a file
set /p S=pick another one
fc !v%F%! !v%S%! > Compare.txt


=====================================
Helping others achieve escape felicity

M2


1

Response Number 2
Name: dwarner8
Date: October 12, 2009 at 10:43:24 Pacific
Reply:

WOOT!

Thank you soooo much. I must have flushed by batch file skills down the drain. This really made my day.

CHEERS!

Derek


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


check network drive statu... Split txt file after a gi...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Filename as stored variable

Batch File- Subfolder as a Variable www.computing.net/answers/programming/batch-file-subfolder-as-a-variable/14153.html

Program to add filename as column www.computing.net/answers/programming/program-to-add-filename-as-column/16698.html

Store variable info into txt or so www.computing.net/answers/programming/store-variable-info-into-txt-or-so/16856.html