search multiple files, copy+paste to new folder (batch file software?)


  1. Posts : 1
    Windows 7 32 bit
       #1

    search multiple files, copy+paste to new folder (batch file software?)


    I am a complete newbie when it comes to batch files and batch file software, so apologies in advance.

    I've done some research on Google etc but I seem to just be getting more and more confused trying to use various different scripts and programs and reading different info on various websites.

    This is what I need...

    I have a folder with around 2000 files in it. I want to be able to copy certain files from this folder (normally around 40) and place them in a brand new folder, I want to be able to do this with nothing more than a txt file that has all the file names I need copying in it with every file name on a separate line.

    I receive around 10 new txt files each day so you can imagine how tedious it is searching through 2000 files, picking out the 40 I need, 10 times a day everyday.

    To make things even more complicated, the txt files I receive don't always have the correct file names in them, maybe there's a misspelling or a word or two missing for some of the names. That's ok when I'm going through picking out the files I need to copy myself because I can normally tell which file is being requested, but I can't see it being so easy for a program or whatever to do, I'm guessing it'll need to have a search feature where it picks out the most likely file.

    I'd like it to be as automated as possible. I receive the txt file, make sure each file name is on a separate line then a program or script or whatever goes out and picks out the files (or most likely files for the name's that aren't exact matches) and copies them into a brand new folder (which I'd like to be the same name as the text file it's using to choose the files).

    I hope this makes sense, I've probably made it sound a lot more complicated than I needed to, I've been looking for a solution for weeks now so my brains gone a bit foggy :/

    I'd appreciate any help you can offer!
      My Computer


  2. Posts : 194
    Windows 10 x64
       #2

    Contact Rent-A-Coder, Elance, or any of the other programming for hire sites. They could knock this out pretty quickly I would think.
      My Computer


  3. Posts : 640
    Windows 7 Ultimate x64
       #3

    Code:
    @echo off
    rem Text file with filenames
    rem To be prompted for this change to  'set /p LIST=Path to text file: '
    rem Or 'set LIST=%1' to run from cmd line like, filename.bat "D:\List.txt"
    set LIST="D:\List.txt"
    
    rem Path to the files to copy
    rem Can be change the same as LIST
    rem Or 'set FILESPATH=%2' to run like , filename.bat "D:\List.txt" "D:\Test"
    set FILESPATH="D:\Test"
    
    rem Destination path can be added here. eg set DESTPATH=C:\New Folder
    rem If set change xcopy cmd to "%DESTPATH%\%DEST%\*"
    rem Do not use quotes when setting DESTPATH
    
    rem Set Destination folder based on LIST name
    for %%i in (%LIST%) do set DEST=%%~ni
    
    rem Read LIST and call :COPY_FILES for each line passing the line of text
    for /F "usebackq delims==" %%i in (%LIST%) do (call :COPY_FILES "%%i")
    
    exit
    
    :COPY_FILES
    rem Destination folder created in same location the batch file is run from
    xcopy /qv %FILESPATH%\%1 .\%DEST%\*
    This is a simple batch file that will do the first part but for the incorrect filenames thats a lot harder.

    There's only two options that I think will work with this script and that's to create a text file of any files that are not found (incorrect names) then manually copy them or using substrings with wildcards which probably won't work very well.

    You might have better luck asking on a scripting forum but I don't think so. The problem I see is to find possible matches you need to break the string up and find files that contain the broken up parts of the string and use wildcards.

    For example you had the file listed as "Seven orums" and you had the files
    Seven Dwarfs
    The Last Seven
    Instruments
    Seven Forums

    Now if you search for Seven* (* = any char) then it would return Seven Dwarfs and Seven Forums. If you search for *orums, it would return Seven Forums.

    But how do we break it up,
    *rum* = Instruments
    Sev* = Seven Dwarfs, Seven Forums
    *Sev* = Seven Dwarfs, The Last Seven, Seven Forums
    ven* = Nothing
    *en oru* = Nothing

    To many possibilties and out of 2000 files how many would be returned with partital matches?

    I don't know if there would be any 3rd party software that could do this either.
      My Computer


  4. Posts : 640
    Windows 7 Ultimate x64
       #4

    Improved code for multiple List files in one folder. I left the old code there because the comments are still valid except the destination path is included in this one.
    Code:
    @echo off
    
    set LISTFOLDER=D:\List Files
    set FILESPATH=D:\Test
    set DESTPATH=D:\New Folder
    
    for /f "tokens=*" %%i in ('dir /b ^"%LISTFOLDER%\*.txt^"') do (call :COPY_FILES "%LISTFOLDER%\%%i")
    
    pause
    exit
    
    :COPY_FILES
    for %%i in (%1) do set DEST=%%~ni
    for /f "usebackq delims==" %%i in (%1) do xcopy /qv "%FILESPATH%\%%i" "%DESTPATH%\%DEST%\*"
      My Computer


  5. Posts : 4
    windows 7 home premium 32 bit
       #5

    To revive this thread, i also have this need. Ie, folders with thousands of file names to search through in the hope of copying 20 of them into a new folder. Unlike Insatiable 11, my file names are reliably correct.

    My journey of understanding batch scripts began this morning.
    Can anyone recommend a thread/tutorial, which can help me interpret Duzzy's posts, so I can create a working batch file using his recommended formulas?

    cheers all..
      My Computer


  6. Posts : 4
    windows 7 home premium 32 bit
       #6

    anyone?
      My Computer


  7. Posts : 1
    ultimate x64
       #7

    Use the Image finder,
    by Fundy Software
    This program has been discontinued

    Run as Adobe Air
    search multiple files, copy+paste to new folder (batch file software?) Attached Files
      My Computer


  8. Posts : 1
    64
       #8

    I have no idea.
      My Computer


  9. Posts : 1
    7 64 bit PRO
       #9

    Not working it says :

    FILE NOT FOUND
      My Computer


  10. Posts : 1
    Maharashtra
       #10

    Rander said:
    Use the Image finder,
    by Fundy Software
    This program has been discontinued

    Run as Adobe Air
    I cant't thank you enough for gr8 help.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 05:47.
Find Us