"Justin Fancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I need a command that will list, in all subdirectories as well, all
> Directories that contain a file, for example "sample.txt".
>
> My preferred output would look like this:
>
> wwwroot/aviation/
> wwwroot/aviation/CACCRA/
> wwwroot/samplefolder/hhyj
> wwwroot/samplefolder2/samplesubfolder/samplesubfolder3
>
>
> If anybody has the correct syntax, could you please send it along.
> Thanks.
>
> Justin Fancy
>
Another problem princess? Oh - we are honoured.
----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for /r . %%i in (.) do if exist %%i\sample.txt set ypf=%%~pnxi&echo
!ypf:~1!
[4]for /r . %%i in (.) do if exist %%i\sample.txt set ypf=%%~pnxi&set
ypf=!ypf:~1!&echo !ypf:\=/!
------ batch ends --------
Lines start [number] - any lines not starting [number] have been wrapped
and should be rejoined. The [number] that starts the line should be removed
%varname% will be evaluated as the value of VARNAME at the time that
the line is PARSED. The ENABLEDELAYEDEXPANSION option to SETLOCAL causes
!varname! tobe evaluated as the CURRENT value of VARNAME - that is, as
modified by the operation of the FOR
Line [3] shows the output with "\"
Line [4] shows the output with "\" converted to "/"
The "." directly following the /r in [3] and [4] is the relative root from
which to scan, "." meaning "current directory" as usual.
|