15.6.06

Create a Text File Dynamically with User Input

The following code in a batch file (.bat)

echo Something to write to text file > %TEMP%/test.txt

creates a text file in temp-directory of system with the content in echo-command.

If one needs to append more lines to the text file, ">" becomes ">>". When only ">" is used, then the text file is overwritten everytime, the echo command is called.

For example, if one wants to create a reg-file according to the input parametrs of a batch file, i.e.

test.bat abc 1000 Admin

then following coding will be helpful;

@echo off
cls
echo.
if exist %TEMP%\%1.reg
goto createFile

:createFile
echo REGEDIT4 > %TEMP%\%1.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Something] >> %TEMP%\%1.reg
echo "Entry1"="%2" >> %TEMP%\%1.reg
echo "Entry2"="%3" >> %TEMP%\%1.reg

regedit /s %TEMP%\%1.reg

pause
del %TEMP%\%1.reg

Nvidia's GauGan App

NVIDIA's GauGAN AI Machine Learning Tool creates photorealistic images from Simple Hand Doodling http://nvidia-research-mingyuliu.com/...