BigFix User Group

You are not logged in.

#1 2009-10-29 08:39:08

Steve
BES Guru
From: England
Registered: 2006-08-25
Posts: 107

Line of file in multiple unknwon folders

Hi Chaps

Working on a query at the mo' to read 2 lines from a file if it exists.
This is not a problem but it's the folder structure that's confusing me a little

Example:

I have the first part of the folder structure, let's say D:\Folder1
Under folder 1 are multiple folders whose names I don't know and each of these folder has a file in them that I want to read. The file name is the same under all these folders and the lines contain the same string value I can look for.

So as follows I would need to read 2 particular lines (if they exist) in the file (if it exists) under each of the unknown folders:

D:\folder1\unknownfoldername1\file.txt
D:\folder1\unknownfoldername2\file.txt
D:\folder1\unknownfoldername3\file.txt
D:\folder1\unknownfoldername4\file.txt

etc.......


Am I making sense here?
Advice appreciated

Cheers

Offline

 

#2 2009-10-29 10:40:27

boyd
BES Guru
From: Pennsylvania
Registered: 2009-06-17
Posts: 240
Website

Re: Line of file in multiple unknwon folders

I think this will work for you. I didn't test it very thoroughly though...

Code:

lines of ((files of folders of folder "D:\folder1") whose (name of it = "file.txt"))

I wasn't sure what lines of the file you wanted so I chose to return all of them...

Offline

 

#3 2009-11-02 06:04:55

Steve
BES Guru
From: England
Registered: 2006-08-25
Posts: 107

Re: Line of file in multiple unknwon folders

Thanks for the input
I'm making progress but just having an issue with files that don't have the value I'm searching for in them. I want to return these as <none>

This seems to work for some and not others, I think it's dependant on whether the first file it hits has the value or not:

Q: (following texts of lasts "deflate_module " of lines whose (it as string as lowercase starts with "loadmodule deflate_module ") of ((files of folders of folders of folder "D:\websphere6\ihs1") whose (name of it = "httpd.conf")) as string as lowercase)

A:
modules/mod_deflate.so
modules/mod_deflate.so
modules/mod_deflate.so

So there may be for instance 8 of the "httpd.conf" files in 8 folder locations but I'm only getting the results for 3 of them (as abviously the other 5 don't have the line I'm looking for)
How can I modify this query to return a result for all 8 files, but those without the line present display as "<none>"? i.e:

<none>
modules/mod_deflate.so
modules/mod_deflate.so
<none>
<none>
<none>
modules/mod_deflate.so
<none>

etc....

I've tried an if/else if statement to return the value if it exists and return <none> if it doesn't but I can't get this to work on more than one file.

Cheers

Offline

 

#4 2009-11-02 08:00:09

Steve
BES Guru
From: England
Registered: 2006-08-25
Posts: 107

Re: Line of file in multiple unknwon folders

Used VBScript in the end chaps so no worries about this (although it would be inertesting to figure it out)

Cheers

Offline

 

#5 2009-11-02 22:58:38

jessewk
Product Expert
From: Emeryville, CA
Registered: 2006-07-31
Posts: 1346

Re: Line of file in multiple unknwon folders

Try something like this:

(if (exists line whose (it as string as lowercase starts with "loadmodule deflate_module ") of it) then (following texts of lasts "deflate_module " of lines whose (it as string as lowercase starts with "loadmodule deflate_module ") of it) else ("<none>")) of files whose (name of it as lowercase = "httpd.conf") of folders of folders of folders "D:\websphere6\ihs1"

Offline

 

#6 2009-11-05 04:12:23

Steve
BES Guru
From: England
Registered: 2006-08-25
Posts: 107

Re: Line of file in multiple unknwon folders

Thanks Jesse!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB