Solved

Filesearch

Posted on 2011-09-07
10
309 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 52

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 52

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 52

Expert Comment

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

~bp
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 52

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 52

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

929 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

9 Experts available now in Live!

Get 1:1 Help Now