Best to show by examples:
Before running the batch file I look for file system objects whose names begin with "Lev" and there are two directories by that name. There's also a single directory named "Dirs". After running the batch file nothing has changed.
And I get "%TopDir" echoed two times, which makes sense because the directory "Level1A" contains two subdirectories, one named "Level 2A" and one named "Level 2B".
I have changed the "@Echo %%TopDir" to "@Echo %TopDir" so that the contents of the "TopDir" variable will by echoed. I make no other changes. And when I run the batch file the first time after making that change I get "can not find the file specified" (for a file named "Dir") and a complaint that the file exists (for a file named simply "Level"). I can not see any references to a file with either name in the batch file. And after running the batch file, a zero-length file named "Level" does indeed exist. Why? How?
So I run the changed version a second time:
This time I get two messages that "Z:\Level" exists (and no more message about a file named "Dir"). And nothing else has changed.
I must admit that I have no clue as to where it is making a reference to a file named "Dir" nor do I understand where it is referencing in any way a file named "Z:\Level".
What on earth am I not seeing?
Code:
Mon Jan 7, 2013 5:37:37a
TCC 14.03.53 x64 Windows 7 [Version 6.1.7601]
Copyright 2012 JP Software Inc. All Rights Reserved
Registered to ****** *******
[Z:\]*Dir /K /M Lev*
1/07/2013 4:43 <DIR> Level 1A
1/07/2013 4:44 <DIR> Level 1B
[Z:\]*Dir /K /M Dir*
1/06/2013 19:35 <DIR> Dirs
[Z:\]Type Demo.btm
SetLocal
PDir /AD "Level 1A\Level*"
Do TopDir In /P PDir /AD "Level 1A\Level*"
@Echo %%TopDir
EndDo
EndLocal
[Z:\]Demo
PDir /AD "Level 1A\Level*"
1/07/2013 4:43 <DIR> Level 2A
1/07/2013 4:43 <DIR> Level 2B
Do TopDir In /P PDir /AD "Level 1A\Level*"
%TopDir
%TopDir
[Z:\]*Dir /K /M Lev*
1/07/2013 4:43 <DIR> Level 1A
1/07/2013 4:44 <DIR> Level 1B
[Z:\]*Dir /K /M Dir*
1/06/2013 19:35 <DIR> Dirs
And I get "%TopDir" echoed two times, which makes sense because the directory "Level1A" contains two subdirectories, one named "Level 2A" and one named "Level 2B".
Code:
[Z:\]Type Demo.btm
SetLocal
PDir /AD "Level 1A\Level*"
Do TopDir In /P PDir /AD "Level 1A\Level*"
@Echo %TopDir
EndDo
EndLocal
[Z:\]Demo
PDir /AD "Level 1A\Level*"
1/07/2013 4:43 <DIR> Level 2A
1/07/2013 4:43 <DIR> Level 2B
Do TopDir In /P PDir /AD "Level 1A\Level*"
TCC: (Sys) Z:\Demo.btm [3] The system cannot find the file specified.
"Z:\DIR"
TCC: (Sys) Z:\Demo.btm [3] The file exists.
"Z:\Level"
[Z:\]*Dir /K /M Lev*
1/07/2013 4:43 <DIR> Level 1A
1/07/2013 4:44 <DIR> Level 1B
1/07/2013 5:36 0 Level
[Z:\]*Dir /K /M Dir*
1/06/2013 19:35 <DIR> Dirs
So I run the changed version a second time:
Code:
[Z:\]Demo
PDir /AD "Level 1A\Level*"
1/07/2013 4:43 <DIR> Level 2A
1/07/2013 4:43 <DIR> Level 2B
Do TopDir In /P PDir /AD "Level 1A\Level*"
TCC: (Sys) Z:\Demo.btm [3] The file exists.
"Z:\Level"
TCC: (Sys) Z:\Demo.btm [3] The file exists.
"Z:\Level"
[Z:\]*Dir /K /M Lev*
1/07/2013 4:43 <DIR> Level 1A
1/07/2013 4:44 <DIR> Level 1B
1/07/2013 5:36 0 Level
[Z:\]*Dir /K /M Dir*
1/06/2013 19:35 <DIR> Dirs
[Z:\]
I must admit that I have no clue as to where it is making a reference to a file named "Dir" nor do I understand where it is referencing in any way a file named "Z:\Level".
What on earth am I not seeing?