Solved Need help with TYPE command. Y it no work?

April 17, 2012 at 07:55:41
Specs: Windows 7
I am trying to make a simple batch that makes a folder called game (unless it already exists) and put text in a .txt file (unless it's already there) then show that text inside the command shell. Its a simple script to write but I'm obviously doing something wrong.

Heres the script so far;
@echo off
setlocal enabledelayedexpansion
:first
if not exist "%userprofile%/Desktop/game" (goto next) else (goto start)
:next
mkdir "%userprofile%/desktop/game"
goto start
:start
if not exist "%userprofile%/Desktop/game/inventory.txt" (goto nxt) else (goto after)
:nxt
echo If you see this it worked >> "%userprofile%/Desktop/game/inventory.txt"
:after
type "%userprofile%/Desktop/game/inventory.txt"
pause


See More: Need help with TYPE command. Y it no work?

Report •


#1
April 17, 2012 at 08:55:27
✔ Best Answer
@echo off

if not exist "%userprofile%\Desktop\game" mkdir "%userprofile%\Desktop\game"
if not exist "%userprofile%\Desktop\game\inventory.txt" echo.if you see this it worked >> "%userprofile%\Desktop\game\inventory.txt"

type "%userprofile%\Desktop\game\inventory.txt"
pause


Report •

#2
April 17, 2012 at 08:57:37
IVO beat me.

Tony


Report •

#3
April 17, 2012 at 13:39:33
Thanks. Its saddens me to see the answer is sooooo easy. I tend to overuse goto

Report •

Related Solutions

#4
April 17, 2012 at 15:48:29
Note: The initial problem is that TYPE doesn't like to use '/' as a substitute for '\' in paths.

How To Ask Questions The Smart Way


Report •


Ask Question