Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Batch script to search folders for listed files

    Good Afternoon,

    I am trying at current with the below to run a batch file that will search all folders in a root directory for specified listed files. It doesn't appear my below batch file searches sub-folders though, Any help would be greatly appreciated.

    @echo off
    set LIST="C:\FTP\PP Root\List\List.txt"
    set FILESPATH="C:\FTP\
    set DESTPATH=C:\FTP\PP Root\Offshore QA\Folder 1
    for %%i in (%LIST%) do set DEST=%%~ni
    for /F "usebackq delims==" %%i in (%LIST%) do (call :COPY_FILES "%%i")
    :COPY_FILES
    xcopy /qv %FILESPATH%\%1 .\%DEST%\*
    Last edited by DarrenMF; 2012-11-02 at 08:51.

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    2,833
    Thanks
    19
    Thanked 110 Times in 104 Posts
    I must say I'm fairly baffled about what you are trying to do, even more so since the variable DESTPATH does not appear to be being used.
    Are you trying to find whether any of the files specified in LIST.TXT exists in each directory/subdirectory, and if so, you want to copy them 'somewhere'?

    Other observations:
    * DEST has only a single value - the final one found in your first FOR statement
    * both the second FOR statement AND the XCOPY statement should be followed by a line
    GOTO :EOF
    * FILESPATH when used seems to have a leading double-quote character, but no trailing one

    To get much further you need to answer my initial question, and provide some examples of what file names (presumably) exist in the file LIST.TXT
    Last edited by BATcher; 2012-11-02 at 09:28.
    BATcher

    Dear Diary, today the Hundred Years War started ...

  3. #3
    New Lounger
    Join Date
    Nov 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My apologies, the code i presented has bee somewhat augmented by several departments, what i am trying to attain is within my list.txt i have filename, some differing file formats ie. mp3, wav etc.

    I am attempting to search all folders present in the root directory for these listed filenames and then copy them to a single folder.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,626
    Thanks
    7
    Thanked 231 Times in 219 Posts
    See this post.

    cheers, Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •