Вы находитесь на странице: 1из 2

BATCH FILES:

=============
DE ARCHIVO DE TEXTO A VARIABLE
SetLocal EnableDelayedExpansion
set content=
for /F "delims=" %%i in (test.txt) do set content=!content! %%i

echo %content%
EndLocal
-----------------------------------------------------------------------------------
---
set content=
for /f "delims=" %%i in ('filename') do set content=%content% %%i
-----------------------------------------------------------------------------------
------
set /p VAR1=<test.txt
-----------------------------------------------------------------------------------
-------
for /f "tokens=1 delims=" %%i in (file.txt) do call :part2 %%i
goto :fin

:part2
echo %1
::do further processing here
goto :eof

:fin
-----------------------------------------------------------------------------------
0
down vote

Create a file called "SetFile.bat" that contains the following line with no
carriage return at the end of it...

set FileContents=

Then in your batch file do something like this...

@echo off
copy SetFile.bat + %1 $tmp$.bat > nul
call $tmp$.bat
del $tmp$.bat

ECHO %FileContents%

%1 is the name of your input file and %FileContents% will contain the contents of
the input file after the call. This will only work on a one line file though (i.e.
a file containing no carriage returns). You could strip out/replace carriage
returns from the file before calling the %tmp%.bat if needed.

-----------------------------------------------------------------------------------
------
for /f "delims=" %%i in (count.txt) do set c=%%i
echo %c%
pause
-----------------------------------------------------------------------------------
---------
echo 1234 | input %%myvar ; puts "1234" into %myvar%
set myvar=%@line[MYFILE,5] ; puts line 6 into %myvar%
set myfar=%@word[4,%@line[MYFILE,6]] ; puts 5th word of line 7 into %myvar%
-----------------------------------------------------------------------------------
------------------
If your data exists on disk, both STRINGS and ASET are able to access diskfiles on
a line-oriented basis. For example:

STRINGS var=read MYFILE,3 # put line 3 of MYFILE into %var%


ASET var=LINE(3,'MYFILE') # put line 3 of MYFILE into %var%

-----------------------------------------------------------------------------------
--------------------
pasa las 3 priomeras lineas del archivo de texto a tres variables
(
set /p var1=
set /p var2=
set /p var3=
)<Filename.txt
-----------------------------------------------------------------

Вам также может понравиться