Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old April 1st, 2008, 06:07 AM
arod arod is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 9 arod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 5 m 56 sec
Reputation Power: 0
DOS Batch - Search for file name string in subfolders

I'm trying to write a batch program that will search a directory and all it's subfolders for word documents that contain a certain string and then copy them into another directory.

I've got code set up to search within a specific directory (directory1), all the .docx files that conatin 'file' and paste them into directory2. If I were to have a number of subdirectories under directory 1, would it be possible to get the batch file to copy all the .docx files that contain 'file' as well?

The problem I have is that the names of the subdirectories will be constantly changing, hence I can't actually specify their names in the batch file.

This is what my current code is:
xcopy C:\working\directory1\file.docx C:\working\directory2 /f /k

Reply With Quote
  Trader Rating: 0 · #2  
Old April 3rd, 2008, 01:55 AM
arod arod is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 9 arod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 5 m 56 sec
Reputation Power: 0
Anybody?

Reply With Quote
  Trader Rating: 2 · #3  
Old April 3rd, 2008, 02:07 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Dev Hardware God (5000 - 5499 posts)
 
Join Date: May 2004
Location: Salem, OH
Posts: 5,374 Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)Nilpo User rank is General 74th Grade (Above 100000 Reputation Level)  Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1Folding Points: 199538 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 Week 3 Days 10 h 10 m 15 sec
Reputation Power: 5908
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
MySpace Orkut
This would be much more feasible using WSH rather than batch. If you are interested in this method, I can put some code together for you.

You want to copy files to a new directly based on a search of their contents, is that right?
__________________
Click the image if at any point you don't like my decision.

10011100011000101111100011100000011000000100000011 10010011011110110001101101011011110100011000001110 0100111101000100001

Visit Nilpo.com and Ask the Windows Guru!

Open me for some very useful links!    

Reply With Quote
  Trader Rating: 0 · #4  
Old May 22nd, 2008, 11:59 PM
sokha sokha is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 2 sokha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 39 sec
Reputation Power: 0
if your subdiretory's name always change, you can copy your batch file to your main directory or subdirectory1 "c:\Working" or "C:\working\directory1" and edit your .bat file like this.
"xcopy /y * C:\Working\directory2"

Note: The option you can add or change by yourself

so it doesn't matter what's your subdirectory's name is, when you double click on your .bat file it will copy all the files to your c:\working\directory2

Does it work?

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > DOS Batch - Search for file name string in subfolders


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT