0
i have the below code which opens cmd and creates some sparse files using user entry to fill in some blanks. what i cant seem to do is to be able to have a line in the code that would be say C:\users\user name\desktop..what i want is to be able to easily insert this "C:\users\user name\desktop" then have the user fill in the "user name" section any ideas on how i would do this ? i tried to enter an echo and then user the arrow up command to copy the line down but that doesnt work so hoping you guys have something easier thanks
@echo off
:start
COLOR 9B
TITLE Batch File Creation
echo ************************
echo * SPARSE FILE CREATION *
echo ************************
echo Standard File Sizes:
echo - 5mb = 5000000 bytes
echo - 10mb = 10000000 bytes
echo - 15mb = 15000000 bytes
echo - 20mb = 20000000 bytes
echo - File types can be any e.g. (xls, xlsx, jpg, png, doc, etc)
echo ************************
echo.
echo.
echo.
echo desktop path location is "c:\users\*your user name*\Desktop"
set /p _path=Enter the file Path :
set /p fname=Enter the Filename (e.g. test.xls) :
set /p fsize=Enter the filesize (in Mb) :
set /a sizeinbytes=fsize*1000*1000
fsutil file createnew %_path%\%fname% %sizeinbytes%
fsutil sparse setflag %_path%\%fname%
fsutil sparse setflag %_path%\%fname% 0 %sizeinbytes%
echo %fname% File Created!!
set /p _new=Would you like to create another file? [y]es, [n]o:
If /i "%_new%"== "y" GOTO :start Else end
end
thanks for that ..one more..can you pass the userprofile to the below line
{fsutil file createnew %_path%\%fname% %sizeinbytes%
so i can save time entering it manuall each time ? – Aaron Rice – 2017-07-14T17:31:53.993Yes. Replace
%_path%\%fname%
with"c:\users\%userprofile%\Desktop\%fname%"
. Use"
around the whole thing in case it contains spaces. Removeset /p _path=Enter the file Path :
as you don't need it any more. – DavidPostill – 2017-07-14T17:38:14.987