You are not logged in.
Pages: 1
can I create file named as environmental variable the code I have below doesn't work
@echo on
title File Maker
if "%~1"=="/?" (
echo.
echo mk /f /d /? [File Name]
echo /f - create file
echo /d - create folder
echo file name the name of the file you wish to create.
goto x
)
if "%~1"=="/f" (
goto file
)
if "%~1"=="/d" (
goto directory
)
:file
if "%~2"=="" (
set "name=%~2"
Echo. 2> %name%
exit /b
)
:directory
if "%~2"=="" (
set "name=%~2"
md %name%
)
:x
thanks
Last edited by Batcher (22 Dec 2015 01:37)
Offline
2>
will redirect anything that outputs to STDERR to a text file. Since echo doesn't throw an error when you use it, nothing is going to be sent. Use
1>
instead.
Offline
2>
will redirect anything that outputs to STDERR to a text file. Since echo doesn't throw an error when you use it, nothing is going to be sent. Use
1>
instead.
Shadow Theif this code is still unable to make a file with the name the user enters.
Offline
Never mind this works
set "name=%~1"
echo. 3> %name%
echo %name%
exit /b
Offline
Pages: 1