By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!In CMD.exe, I can do something like cd *doc*, and it will change into the first matching directory. TCC LE didn't like this. Is this an appropriate replacement? It seems to work.
cd %@FINDFIRST[%1*]
In a batch file.... I can't imagine why you'd ever want an indeterminate CD in a batch file. But if you're going to use @FINDFIRST, be sure to call @FINDCLOSE afterwards to free up the search handle. It might be easier to call @EXPAND and strip off the first word.
I also want to sometimes build the current dir, . or the parent, .. Neither findfirst nor expand resolve .* or ..*, so it looks like I must add special logic for this. Any thoughts here?
No, expanding either of those will be an arbitrary directory, and not the current directory or the parent directory.Should that be .\* and ..\* ?
2/02/2010 10:50 DIR .
2/02/2010 10:50 DIR ..
2/02/2010 10:20 DIR .svn
2/02/2010 10:21 DIR apache-ssl
2/02/2010 10:38 DIR logs
> ---Quote (Originally by Charles Dye)---
> Should that be .\* and ..\* ?
> ---End Quote---
> No, expanding either of those will be an arbitrary directory, and not the
> current directory or the parent directory.
>
> What this seems to boil down to is that . and .. are not in the list of
> directories listed by EXPAND or FINDFIRST...
>
> Here's what dir /ad shows: 2/02/2010 10:50 <DIR> .
> 2/02/2010 10:50 <DIR> ..
> 2/02/2010 10:20 <DIR> .svn
> 2/02/2010 10:21 <DIR> apache-ssl
> 2/02/2010 10:38 <DIR> logs
>
> And here is what %@EXPAND[*, d] shows:
> .svn apache-ssl logs
>
> Note the missing entries... Is there a way to add these special directories
> back in? I'd have less crazy if logic, if I could.
>
>
>
>
>
What this seems to boil down to is that . and .. are not in the list of directories listed by EXPAND or FINDFIRST...
Here's what dir /ad shows:
And here is what %@EXPAND[*, d] shows:Code:2/02/2010 10:50 DIR . 2/02/2010 10:50 DIR .. 2/02/2010 10:20 DIR .svn 2/02/2010 10:21 DIR apache-ssl 2/02/2010 10:38 DIR logs
.svn apache-ssl logsNote the missing entries... Is there a way to add these special directories back in? I'd have less crazy if logic, if I could.
set dirs="%_cwd" "%@truename[..]" %@expand[*,d]
Does something like %@expand[%@full[.]] work for you? Using %@full[] with a
pattern simulates what it would look like and keeps the pattern. Using it
with dot gives the cwd.
Something like this, perhaps.... ?
And then use DO /L %DIRS to loop through the list?Code:set dirs="%_cwd" "%@truename[..]" %@expand[*,d]
In CMD.exe, I can do something like cd *doc*, and it will change into the first matching directory. TCC LE didn't like this. Is this an appropriate replacement? It seems to work.cd %@FINDFIRST[%1*]
> ---Quote (Originally by pforhan)---
> What this seems to boil down to is that . and .. are not in the list
> of directories listed by EXPAND or FINDFIRST...
>
> Here's what dir /ad shows:
>
>
> Code:
> ---------
> 2/02/2010 10:50 DIR .
> 2/02/2010 10:50 DIR ..
> 2/02/2010 10:20 DIR .svn
> 2/02/2010 10:21 DIR apache-ssl
> 2/02/2010 10:38 DIR logs
> ---------
> And here is what %@EXPAND[*, d] shows:
> .svn apache-ssl logs
>
> Note the missing entries... Is there a way to add these special
> directories back in? I'd have less crazy if logic, if I could.
> ---End Quote---
> Something like this, perhaps.... ?
>
>
> Code:
> ---------
> set dirs="%_cwd" "%@truename[..]" %@expand[*,d]
> ---------
> And then use DO /L %DIRS to loop through the list?
>
>
>
>
Forgive me for jumping into this mid-conversation as I may be stating
something obvious, but doesn't this do what you want?
for /a:d %d in (*) do echo %d
No, it WAD. FOR has an option to suppress the dot directories: /H, provided
many years ago at the request of lots of users. Your usage is the first I
came across that actually desires the . and .. directories in my many years
of using command processors.
cd longNamedDomain
mvn clean install
cd ../longNamedServer
mvn clean install
cd ../longNamedClient
mvn clean install
cd ../longNamedDistribution
mvn deploy
cd..
selbuild *dom *serv *cli deploy *dist
selbuild ..\*dom ..\*serv . deploy ..\*dist
provided> ---Quote (Originally by Steve Fábián)---
> No, it WAD. FOR has an option to suppress the dot directories: /H,
I> many years ago at the request of lots of users. Your usage is the first
years> came across that actually desires the . and .. directories in my many
> of using command processors.
> ---End Quote---
> That's what I assumed. I know my usage is a bit odd, but so is
> Maven, for anyone who's used it.
>
> Maven allows you define a large hierarchy of projects, but
> frequently you just want to recompile a subset of those. Here's a
> typical use case:
>
>
> Code:
> ---------
> cd longNamedDomain
> mvn clean install
> cd ../longNamedServer
> mvn clean install
> cd ../longNamedClient
> mvn clean install
> cd ../longNamedDistribution
> mvn deploy
> cd..
> ---------
> ... annoying. But I found myself doing that because I didn't want
> to build the other 20 parts of the project, in order to save time.
> So, I wrote a script that lets me do the above, all in one line,
> failing fast if there was a problem:
>
>
> Code:
> ---------
> selbuild *dom *serv *cli deploy *dist
> ---------
> There are rare cases where I'm already in one of those subdirs, so I
> want to reference '.' -- for example, assuming I'm in client:
>
>
> Code:
> ---------
> selbuild ..\*dom ..\*serv . deploy ..\*dist
> ---------
> I think this is a huge win. I'd be happy to share the script if
> anyone would like to take a look.
>
>
>
>
I assume that the issue is the expanding of the wildcard directory names
you've specified as the arguments to selbuild.
cd %1*
rem change to requested dir. Use special rules when running under TCC:
if (%@EVAL[1+1]%)==(2) goto cdUnderTCC
cd %1*
goto runMvn
:cdUnderTCC
if (%1)==(.) goto runMvn
if (%1)==(..) cd .. & goto runMvn
cd %@WORD[0,%@EXPAND[%1*,d]]
goto runMvn
:runMvn
> ---Quote (Originally by samintz)---
> I assume that the issue is the expanding of the wildcard directory names
> you've specified as the arguments to selbuild.
> ---End Quote---
> Basically, yeah. I can add the if logic to avoid this issue, it's
> just that, in my batch file, I went from this:
>
> Code:
> ---------
> cd %1*
> ---------
> to this:
>
> Code:
> ---------
> rem change to requested dir. Use special rules when running under TCC:
> if (%@EVAL[1+1]%)==(2) goto cdUnderTCC
> cd %1*
> goto runMvn
>
> :cdUnderTCC
> if (%1)==(.) goto runMvn
> if (%1)==(..) cd .. & goto runMvn
> cd %@WORD[0,%@EXPAND[%1*,d]]
> goto runMvn
>
> :runMvn
> ---------
> Granted, if I drop support for CMD, I can drop half those lines.
> This is just a bit more complex, that's all, but it still works.
>
>
>
>