Hi!
Okay, this is my problem:
I want a batch file to check a folder for files, then put (if its a text file) the contents in a variable eg. set variable1=%content_of_file1% or more specific the second line. And it continues like this:
set variable2=%content_of_file2%
set variable3=%content_of_file3%
set variable4=%content_of_file4%
...
Need some file check and variable set help.
Moderator: DosItHelp
Re: Need some file check and variable set help.
Would also like if the batch file could tell which number is biggest out of a bunch of numbers eg. 1 4 7 9. and it would tell me that 9 is the biggest number.
Re: Need some file check and variable set help.
Here a simple solution:
You only have access to the variables as long as the batch runs.
Code: Select all
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set num=0
for /f %%d in (datfile.txt) do if exist %%d (
set /a num+=1
set filename_!num!=%%d
)
echo There are !num! files exist from the list.
pause
You only have access to the variables as long as the batch runs.