|
Answer» I have one .txt file and one .bat file:
VARIABLE.TXT with one LINE:
Code: [Select]variabletext CREATEFILE.BAT
I want CREATEFILE.BAT to create a file with a filename based on the content (variabletext) of VARIABLE.TXT
Does anyone know if this is possible and what command to set in CREATEFILE.BAT? Many THANKS in ADVANCE!
David Look at set /? at the command prompt for more information.
Set /p contents=echo %contents%
NOTE: The above will only work with the FIRST line. If you want to work with all lines, that's a whole different story. C:\>type createfile.bat
Code: [Select]echo off setlocal enabledelayedexpansion for /f "delims=" %%i in (variable.txt) do ( echo %%i set contents=%%i echo contents=!contents! echo newfile > !contents!.txt dir "!contents!.txt" ) Output:
C:\>createfile.bat mynewfile contents=mynewfile Volume in drive C has no label. Volume Serial Number is F4A3-D6B3
DIRECTORY of C:\
03/03/2010 05:58 PM 10 mynewfile.txt 1 File(s) 10 bytes 0 Dir(s) 299,179,556,864 bytes free C:\>greg,
Your example worked like a charm. You guys really helped me out. I appreciate it very much!
David
|