[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Filesearch

Posted on 2011-09-07
10
Medium Priority
?
369 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 58

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 58

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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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 58

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 58

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 58

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Six Sigma Control Plans
Starting up a Project
Suggested Courses

650 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