No announcement yet.

Search for .doc files.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Search for .doc files.

    I have a Windows server 2003 R2 with a directory filled with thousands of Microsoft Word 2003 files. Now i need to extract only a couple a hundred .doc files from that folder. I have a notepad of the files i need to extract. How do i this search using a batch file?

  • #2
    Re: Search for .doc files.

    "For each result of a dir operation on this folder, do something to files which appear in this text file."

    You don't say what exactly you want to do with these files...
    Gareth Howells

    BSc (Hons), MBCS, MCP, MCDST, ICCE

    Any advice is given in good faith and without warranty.

    Please give reputation points if somebody has helped you.

    "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

    "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.


    • #3
      Re: Search for .doc files.

      Sorry about that. I want to extract the files i am searching for and zip them. Example:


      And i need to copy and extract joy.doc and sue.doc.

      That is the example. In reality the amount of files is in the thousands and the amount of files i need to copy and extract are in the thousands also. I tried windows search but not granular enough. any ideas? Not very good at scripting.


      • #4
        Re: Search for .doc files.

        You got a list of files to copy?



        • #5
          Re: Search for .doc files.

          Yes, I have a .txt list


          • #6
            Re: Search for .doc files.

            Try this
            one notepad (or notepad++ if you have it) and type:

            for /f %%a in (<loacation of text file>\FILENAMES.txt) do 7za a -tzip <archive-name> <folder-name>

            <location of text file> Replace with path to your text file
            <archive-name> What you would like to call the zip file
            <folder-name> location of the folder for the zip file
            you will need to have 7zip installed for this to work.

            this should do the trick, but I haven't tested it yet.


            • #7
              Re: Search for .doc files.

              Sorry, I was under the impression (for some reason) you wanted to zip the files.
              not sure what you want to do with them but just replace everything after the "DO" command with what you want to do... for example
              Move %%a z:\recovered


              • #8
                Re: Search for .doc files.

                Originally posted by compguy030471 View Post
                How do i this search using a batch file?

                @echo off
                Set "SrcFldr=Z:\1\ARL"
                For /F "usebackq tokens=*" %%* in ("files.txt") Do call :Chk4Doc %%~*
                :Chk4Doc  + + + Subroutine + + +
                If NOT exist "%SrcFldr%\%*" goto :next1
                Move /y "%SrcFldr%\%*" "%SrcFldr%\SUB\"
                If exist "%SrcFldr%\SUB\%*" echo.%* -- success
                exit /b 0
                Last edited by Rems; 2nd April 2011, 10:28.

                This posting is provided "AS IS" with no warranties, and confers no rights.


                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts


                • #9
                  Re: Search for .doc files.

                  Unless I am misunderstanding:

                  You can create a compressed file (IE: zip) from a list of file names stored inside a file.

                  zip -a @files.lst

                  Where files.lst is the text file with names of all the files to include.

                  Any compression program can do this without any extra programming.