Click here to Skip to main content
11,927,006 members (48,762 online)
Rate this:
Please Sign up or sign in to vote.
See more: batch
                          ║        My Folder         ║
                          ║1. Create Folder          ║
                          ║2. Delete Folder          ║
                          ║3. Move Folder            ║
                          ║                          ║
                          ║                          ║
                          ║                          ║
                          ║                          ║
Enter Menu Number: [1,2,3]?1
Folder Name:joje
A subdirectory or file joje already exists.
why "Successful!" is echoed? since it will only prompt if it goes to :create folder command..pls HELP me Frown | :( ..btw my OS is win7
Choice /C 123 /M "Enter Menu Number:"
If errorlevel 1 Goto 1
If errorlevel 2 Goto 2
If errorlevel 3 Goto 3

set /p folderName=Folder Name:
if not exist '%folderName%' goto :createFolder

md %folderName%
echo Successful!
pause > nul
goto myFolder
Posted 4-Aug-12 3:43am
Wes Aday 4-Aug-12 9:25am
if not exist '%folderName%' goto :createFolder else goto :MyFolder
EjojAnrodac 4-Aug-12 9:30am
Hey Wes! I really appreciate your advice..but still :( ..same output! its still echoing "Successful!"

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I don't see how it could not do that. If it doesn't goto :createFolder, it will fall through to :createFolder. Then it will echo 'successful'. There's no path for it not to do that.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

set /p folderName=Folder Name:
if exist %folderName% goto :error else :yes
md %folderName% (I just have to take this command line out in the :Yes command, strange isn't it?)
echo The folder %folderName% created successfully!
pause > nul
goto :1
echo The folder %folderName% already exist!
Pause > nul
goto :1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 5 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100