Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .bat
                          ╔══════════════════════════╗
                          ║        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.
Successful!
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
====================================================================================
:MyFolder
Choice /C 123 /M "Enter Menu Number:"
If errorlevel 1 Goto 1
If errorlevel 2 Goto 2
If errorlevel 3 Goto 3
 
:1
set /p folderName=Folder Name:
if not exist '%folderName%' goto :createFolder
 
:createFolder
md %folderName%
echo Successful!
pause > nul
goto myFolder
Posted 4-Aug-12 3:43am
Comments
Wes Aday at 4-Aug-12 9:25am
   
if not exist '%folderName%' goto :createFolder else goto :MyFolder
EjojAnrodac at 4-Aug-12 9:30am
   
Hey Wes! I really appreciate your advice..but still :( ..same output! its still echoing "Successful!"
 
T_T
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

:createFolder
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?)
 
:yes
echo The folder %folderName% created successfully!
pause > nul
goto :1
exit
 
:error
echo The folder %folderName% already exist!
Pause > nul
goto :1
exit
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 520
1 Maciej Los 290
2 Richard MacCutchan 265
3 BillWoodruff 265
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 5 Aug 2012
Copyright © CodeProject, 1999-2014
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