1

Someone help me to create a batch file to extract information from a file and create another with that information?

The file "version.log" contains only the information "v1.0"

I want to create a text file with that information "v1.0.txt"

2 Answers 2

2

This should work just fine:

@echo off
set /p VERSION= < version.log
echo "nothing" > "%VERSION%.txt"
3
  • 2
    Or a type nul instead of echo "nothing", if you want an empty file.
    – Bob
    Jul 6, 2012 at 21:30
  • @Bob: Cool. I wanted to write touch first, but couldn't come up with the Windows equivalent. Thanks! :) Jul 6, 2012 at 21:31
  • That's exactly what I wanted. Very very thank you very much
    – Rui Aguiar
    Jul 6, 2012 at 21:43
2

XYZ

@echo off
setlocal

set FILE=log.txt
:: Read first line of the file
for /F "tokens=*" %%x in (%FILE%) do (set STR=%%x) && (goto out)
:out
fsutil file createnew %STR% 0
pause 1>nul
1
  • 1
    fsutil file createnew %STR%.txt 0?
    – martineau
    Jul 7, 2012 at 2:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .