PC Review


Reply
Thread Tools Rate Thread

Applications listing

 
 
Justin Fancy
Guest
Posts: n/a
 
      21st Nov 2006
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

 
Reply With Quote
 
 
 
 
billious
Guest
Posts: n/a
 
      21st Nov 2006

"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.


 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      21st Nov 2006
> -----Original Message-----
> From: Justin Fancy [private.php?do=newpm&u=]
> Posted At: Tuesday, November 21, 2006 5:44 PM
> Posted To: microsoft.public.win2000.cmdprompt.admin
> Conversation: Applications listing
> Subject: Applications listing
>
> 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
>


In addition to billious's reply, here's another way to accomplish this:

@echo off
set rootdir=c:\mydir
set file=sample.txt
for /f %%i in (
'dir /b /s "%rootdir%\%file%"') do echo %%~dpi

--
Alexander Suhovey

 
Reply With Quote
 
Justin Fancy
Guest
Posts: n/a
 
      21st Nov 2006
I need to search for all "*.asp" files and all "web.config" files that
are in any of the folders and subfolders. Shall I just substitute the
values?

 
Reply With Quote
 
Justin Fancy
Guest
Posts: n/a
 
      21st Nov 2006
Oh and I need some more things if its possible PRINCESS!! hahaha.

I need to display only the unique directory names, but I also need a
count for all the files found in that directory.

Output example:

/wwwroot/justin/isaprincess/;89
/wwwroot/me/no/you/;94

Can it be done!??

J

 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      21st Nov 2006
"Justin Fancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Oh and I need some more things if its possible PRINCESS!! hahaha.


I don't get it, what's the deal with "PRINCESS" thing? Did I miss something?

> I need to display only the unique directory names


With static file names you can just go ahead and substitute file name in my
initial example. For wildcards like *.asp however... that wouldn't quite
work. As you probably already noticed, script will produce one line of
output per file found so in case of folder with multiple asp files you'l see
multiple occurencies of folder name in the output.

> , but I also need a count for all the files found in that directory.


Yes, that too can be done. Consider following example which wasn't heavily
tested but worked for me:

@echo off
setlocal enabledelayedexpansion
set rootdir=c:\inetpub\wwwroot
set file=*.asp
set folder=%rootdir%&set n=0
for /f "delims=" %%i in (
'dir /b /s "%rootdir%\%file%"') do (
if "!folder!"=="%%~dpi" (
set /a n+=1
) else (
if !n! GTR 0 echo !folder!^;!n!
set n=1
set folder=%%~dpi
)
)




--
Alexander Suhovey

 
Reply With Quote
 
Justin Fancy
Guest
Posts: n/a
 
      22nd Nov 2006

Alex, whoever this guy/girl is calling me "Princess", i just went along
with him/her. haha...

Anyway, the script doesn't seem to work for me?

I'm mapping a network drive and then searching that drive. Here's mine:

@echo off
net use x: \\tc2s03\d$
setlocal enabledelayedexpansion
set rootdir=x:
set file=*.asp
set folder=%rootdir%&set n=0
for /f "delims=" %%i in (
'dir /b /s "%rootdir%\%file%" > output.txt') do (
if "!folder!"=="%%~dpi" (
set /a n+=1
) else (
if !n! GTR 0 echo !folder!^;!n!
set n=1
set folder=%%~dpi
)
)
)

 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      22nd Nov 2006
"Justin Fancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Anyway, the script doesn't seem to work for me?


It will not work because you changed it to redirect all DIR output to
output.txt file so FOR command doesn't have anything to process. In
following example command_2 will never execute:

for /f "delims=" %%i in ('command_1 > output.txt') do (command_2)

--
Alexander Suhovey

 
Reply With Quote
 
Justin Fancy
Guest
Posts: n/a
 
      22nd Nov 2006

So how would I program this correctly so I can ouput it to a textfile?

 
Reply With Quote
 
Alexander Suhovey
Guest
Posts: n/a
 
      22nd Nov 2006
"Justin Fancy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> So how would I program this correctly so I can ouput it to a textfile?


Depends on what do you mean by "it". If you want script output to be saved
to a file, don't alter script itself, just use:

script.cmd > output.txt

If you need to duplicate script output to both stdout AND to a file, use:

for /f "delims=" %%i in ('script.cmd') do (
echo %%i
echo %%i >>output.txt
)

--
Alexander Suhovey

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a custom listing in all applications context menu Jay Douglas Microsoft C# .NET 3 12th Nov 2008 05:03 PM
Listing running applications and their icons pigeonrandle Microsoft C# .NET 1 2nd Jan 2007 09:41 PM
Default listing settings from within applications XP G3WIP Windows XP General 1 29th Mar 2005 04:55 AM
Windows active directory, listing users applications/processes =?Utf-8?B?TWljaGFlbCBIdWdoZXM=?= Microsoft Windows 2000 Active Directory 1 19th Mar 2005 07:38 AM
Ports and applications that are listing on them. George Wangolo Microsoft Windows 2000 Networking 1 28th Jan 2004 06:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 PM.