You are not logged in.
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
I think this will work for you. I didn't test it very thoroughly though...
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
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
Used VBScript in the end chaps so no worries about this (although it would be inertesting to figure it out)
Cheers
Offline
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
Thanks Jesse!
Offline