Page 1 of 1

chdir to list files

Posted: 24 Sep 2015 04:07
by johnpc
I have 3 temp directories temp, temp1, temp3. I would like to create a batch file that displays their contents.
This is what I have written but it doesn't work

@echo off
cd c:\
dir\temp/p
pause

cd c:\
dir\temp1/p
pause

Any ideas?

Re: chdir to list files

Posted: 24 Sep 2015 06:36
by Squashman

Code: Select all

dir C:\Temp C:\Temp1 C:\Temp3

Re: chdir to list files

Posted: 25 Sep 2015 00:53
by johnpc
Dose not seem to work.

Re: chdir to list files

Posted: 25 Sep 2015 06:48
by Squashman
johnpc wrote:Dose not seem to work.

Strange. I must be special then.

Code: Select all

C:\>dir C:\Temp C:\Temp1 C:\Temp3
 Volume in drive C is 13_06P
 Volume Serial Number is 5AE4-90D0

 Directory of C:\Temp

09/25/2015  07:47 AM    <DIR>          .
09/25/2015  07:47 AM    <DIR>          ..
12/10/2013  04:31 PM    <DIR>          convert
01/20/2014  12:41 PM    <DIR>          DBF_Convert
               0 File(s)              0 bytes

 Directory of C:\Temp1

09/25/2015  07:47 AM    <DIR>          .
09/25/2015  07:47 AM    <DIR>          ..
09/25/2015  07:47 AM                 6 File1.txt
               1 File(s)              6 bytes

 Directory of C:\Temp3

09/25/2015  07:47 AM    <DIR>          .
09/25/2015  07:47 AM    <DIR>          ..
09/25/2015  07:47 AM                 6 File3.txt
               1 File(s)              6 bytes
               2 Dir(s)  198,622,048,256 bytes free

C:\>

Re: chdir to list files

Posted: 25 Sep 2015 15:14
by johnpc
Not as strange or special as me!

Of course it works, I had typed Temp 1, Temp 2 etc. instead of Temp1, Temp2 etc.

Corrected Version:

dir C:\Temp /p C:\Temp1 /p C:\Temp2 /p C:\Temp3 /p
pause

I apologize for misspelling of Does in my previous reply ("Dose not seem to work")

Thank you!

Re: chdir to list files

Posted: 25 Sep 2015 16:16
by Squashman
You only need the /P once.

Re: chdir to list files

Posted: 27 Sep 2015 05:52
by johnpc
Thanks Again.