|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 |
|
|||
|
Anybody?
|
|
||||
|
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!
![]() |
|
|||
|
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? |
![]() |
| Viewing: Dev Hardware Forums > SOFTWARE > Programming > DOS Batch - Search for file name string in subfolders |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|