?
Solved

Filesearch

Posted on 2011-09-07
10
Medium Priority
?
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 56

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 56

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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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 56

Expert Comment

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

~bp
0
 

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 56

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 56

Accepted Solution

by:
Bill Prew earned 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes
Suggested Courses

777 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