Filename as stored variable

Microsoft Windows xp pro w/ sp3 multilin...
October 12, 2009 at 10:01:22
Specs: Windows XP
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:


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

See More: Filename as stored variable

Report •

October 12, 2009 at 10:33:56
@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
set /p F=pick a file
set /p S=pick another one
fc !v%F%! !v%S%! > Compare.txt

Helping others achieve escape felicity


Report •

October 12, 2009 at 10:43:24

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



Report •

Related Solutions

Ask Question