Solved

Filesearch

Posted on 2011-09-07
10
298 Views
Last Modified: 2012-05-12
Hi,

I need to filter out a directory for certain files and put these files into another directory to be able to search for a string in it. I tried textcrawler but it gets stuck since there are to many folders/files.

So what I would like to do is find a decent way to:
1.look for files with name x.config
2.grab them together and put them on another location, however, the folder in which they were should be displayed since all files are x.config and I need to make distinction between them
3.look for a string within these config-files and display this in a word/excel (this textcrawler can do fine)

Thanks for your input.
0
Comment
Question by:janhoedt
  • 5
  • 5
10 Comments
 
LVL 51

Expert Comment

by:Bill Prew
ID: 36495891
Not sure exactly what you are after, but if you are just moving the files to search them, then why not do it all at once?  Perhaps something like:

findstr /S "searchstring" c:\base\x.config

~bp
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 36495919
But, if you really want to use textcrawler on an extract set of files, you should be able to use XCOPY, and do something like:

xcopy "c:\basedir\x.config" "d:\destdir" /S /I

~bp
0
 

Author Comment

by:janhoedt
ID: 36495926
Just a way to find web.config files in an IIS-directory. Because we need to scan the results (web.config) for a certain string (what can be done with textcrawler), I would like to copy all the web.configs into another location but there the folder should be created in which original folder it was (for example site1\web.config, site2\web.config etc.
0
 

Author Comment

by:janhoedt
ID: 36495927
Just a way to find web.config files in an IIS-directory. Because we need to scan the results (web.config) for a certain string (what can be done with textcrawler), I would like to copy all the web.configs into another location but there the folder should be created in which original folder it was (for example site1\web.config, site2\web.config etc.
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 36495939
Okay, xcopy with /S should preserve the folder structure.

~bp
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:janhoedt
ID: 36496065
I'd need only the top folder from which it is copied, now it copies the whole structure.
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 36496080
Can you provide an example?  Like if the source had:

c:\dir1\dir2\dir3\dir4\web.config

where do you want that file copied to?

~bp
0
 

Author Comment

by:janhoedt
ID: 36496167
Ok, this is an example:

c:\dir1\dir2\dir3\web.config

To

c:\temp\dir1\web.config
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 36499214
Okay, I think this should get the job done, let me know what questions you have.  It basically works through each subfolder of the main directory in the outer FOR loop.  Then under each of those looks for any web.config file, and copies it to a directory as you wanted.

@echo off
set BaseDir=c:\base
set DestDir=c:\dest

for /D %%A in ("%BaseDir%\*") do (
  for /F "tokens=*" %%B in ('dir /b /a-d /s "%%~A\web.config"') do (
    if not exist "%DestDir%\%%~nA\" md "%DestDir%\%%~nA"
    copy "%%~B" "%DestDir%\%%~nA"
  )
)

Open in new window

~bp
0
 

Author Closing Comment

by:janhoedt
ID: 36504668
Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is an explanation of a simple data model to help parse a JSON feed
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now