Computing.Net > Forums > Programming > Batch Coding - dir list & file exec

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Coding - dir list & file exec

Reply to Message Icon

Name: Justin B
Date: October 28, 2005 at 18:34:32 Pacific
OS: Windows XP SP2
CPU/Ram: 512 Ram - Pentium IIIV
Comment:

Ok, how do I have a script that lists all the folders within its directory? Then have a question asking with directory the user wants to open.. when they open the folder, have the batch script CALL another .bat script entitled files.bat that is in each directory.

THANKS SO MUCH!



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: October 28, 2005 at 23:42:56 Pacific
Reply:

You already have an application that will do just that. Its called Windows Explorer.

Stuart


0

Response Number 2
Name: Mechanix2Go
Date: October 29, 2005 at 05:44:14 Pacific
Reply:

:: ===== whichDIR
@echo off

if not %1'==' goto :process
dir/ad/b
echo which directory?
set /p dirCHOICE=
%0 %dirCHOICE%
goto :eof

:process
cd %dirCHOICE%
call files.bat
:: === DONE



If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: Justin B
Date: October 30, 2005 at 18:48:42 Pacific
Reply:

first how do I get it to list the numbers infront of the directories?

second, how do I get the numbers represent the directory names?

so if I have two dirs:

1. Directroy One
2. Directory Two

What directory?
1_


and then it would open 'Directory One'.

thanks again everyone!


0

Response Number 4
Name: Justin B
Date: October 30, 2005 at 20:53:05 Pacific
Reply:

Never mind that, this question is more important...

Whats wrong with this statement? (root\subdir\files.bat) roob.bat is located in root\

:: Files.bat
@Echo off
Echo Return to installation menu? 'y' or 'n'
Set /p returnDIR=

if "%returnDIR%"=="y" (
set returnDIR=
CD ..
Call root.bat
pause
)
if "%returnDIR%"=="n" (
set returnDIR=
Exit
)


0

Response Number 5
Name: Mechanix2Go
Date: October 30, 2005 at 22:11:59 Pacific
Reply:

I'm nopt clear on what you want to do here.


If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: StuartS
Date: October 30, 2005 at 22:37:37 Pacific
Reply:

As far I can tell Justin wants to emulate the functions of Windows Explorer which seems a bit of a pointless exercises to me.

If a folder is added or deleted, a new batch file will have to be created to accommodate it unless you use recursive programming which I don't believe you can do with batch files.

Whats wrong with this statement? (root\subdir\files.bat) roob.bat is located in root\

Whats wrong is that there is no such folder with the name root. The root folder is indicated by a single backslash or the leading backslash in a path name. A full path name is alway preceded with a back slash or a drive letter followed by a back slash. The absence of a drive letter indicates the current drive.

\subdir\files.bat means the file in the folder subdir that is in the first level of the root folder.

Stuart


0

Response Number 7
Name: Mechanix2Go
Date: October 30, 2005 at 23:03:48 Pacific
Reply:

Hi StuartS,

Yeah, hard to tell whether he means "the root" or a directory named "root".

And I'm not clear whether the latest question is an enhancement of the original [to provide 'return to start dir'] or a completely separate issue.


If at first you don't succeed, you're about average.

M2


0

Response Number 8
Name: Justin B
Date: October 31, 2005 at 07:29:59 Pacific
Reply:

it was hypothetical. I have found out the problem, it was the fact I typed CD ..

since the folder I am writing these scripts on are C:\folder\folder\folder\root\ that is the root folder for the scripts. subdir is where a second part of the script asking the user if he would like to return to the menu script. The fact that the first one CALLed the second, the Dir is still at C:\folder\folder\folder\root\ not C:\folder\folder\folder\root\subdir where the second part of the script is located.

So with CD .. in place, it was really making the dir C:\folder\folder\folder\ and thats why CALL root.bat or Start root.bat would not work.


I thank you all again very much. Have a nice day!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Coding - dir list & file exec

list all files in a dir & subdir www.computing.net/answers/programming/list-all-files-in-a-dir-amp-subdir/14098.html

Im stuck,pls help.. batch coding www.computing.net/answers/programming/im-stuckpls-help-batch-coding/12018.html

Batch file help www.computing.net/answers/programming/batch-file-help/14346.html