Batch file to Sort and Move specific files by identifying word inside


  1. Posts : 10
    Windows 7 ultimate 32bit
       #1

    Batch file to Sort and Move specific files by identifying word inside


    Hi All...
    I will explain what I need in as much detail as possible.
    I need a batch file to move specific files into a separate folder,possibly by opening my hex editor,searching for the word "body" ( without the quotes ) and if found ,close hex editor,move file to a folder called "moved" ,then go on to the next one.If the word "body" is not found just close hex editor and ignore the file.
    I have approx 900 files in a folder.One is a vehicle and one is a map for a game.They are mixed together and the only way of telling them apart is by opening each one with my hex editor and search for the word "body",which means it is a vehicle.If the "body" word is not found,it is a map.Example wording of the files: mapname.idf carname.idf
    Manually this process would take hours,even days.
    It would be a lot better if there is a way of doing this without using the hex editor/batch idea.
    Here is a link to one map and one vehicle file if needed for an example:
    http://vnovak.com/1nsane/2idf-files.zip
    Thanks a bunch for your help!
    Val :)
      My Computer


  2. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #2

    All files are in 1 folder now? If so tell me the folder name plz.
      My Computer


  3. Posts : 10
    Windows 7 ultimate 32bit
    Thread Starter
       #3

    insanefiles
      My Computer


  4. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #4

    val5662 said:
    insanefiles
    so you want to move all files in folder "insanefiles" (not it's subfolders!) which has text "body" inside. Correct?
    To which folder do you want to move them?
    Please post complete source folder and destination folder. Then I can make a batch file
      My Computer


  5. Posts : 10
    Windows 7 ultimate 32bit
    Thread Starter
       #5

    Insanefiles folder has 900 dot idf ( .idf ) extension files with naturally a different prefix on each.Example > anyname1.idf and anyname2.idf
    If opened with a hex editor and search for the word body , only the vehicle idf has that word inside that idf file.
    I want a batch file I can place inside the insanefiles folder that can be run and detect the body word inside the idf files,then move all those idf files into a folder inside the insanefiles folder named moved.The idf files that did not have the body word inside would be left alone,because a map idf file does not have the word body inside the idf file.
    Thanks!
    Val
      My Computer


  6. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #6

    This has be done once? Or should it be a perfect batch script?
      My Computer


  7. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #7

    Step 1: Create the folder called moved as subfolder.
    Step 2: Open notepad and paste this code inside:
    Code:
    @echo off
    for /f %%i in ('findstr /i /m "body" *.idf') do echo move "%%i" moved
    pause
    Save it and call the file movebody.cmd. Put the file in same folder as the *.idf files.
    Step 3: Doubleclick on movebody.cmd. You see something like:
    move somefile.idf moved
    move someotherfile.idf moved
    ???
    somefile.idf and someotherfile.idf are the correct files to move?
    Remove the word "echo" inside the cmd file and run it again. Files are indeed moved? Run it again.... no files moved?
    Last edited by Kaktussoft; 03 Oct 2014 at 03:25.
      My Computer


  8. Posts : 10
    Windows 7 ultimate 32bit
    Thread Starter
       #8

    Thanks....I had to modify it like below and it worked but now I have a new problem.
    A lot of these idf files have the word body with caps like Body or BODY and the code below just ignores those files.
    How can I modify this code to make it NOT case sensitive?
    Thanks again!

    @echo off
    md moved
    for /f "eol=: delims=" %%F in ('findstr /m body *.idf') do @move "%%F" moved >nul
    pause
      My Computer


  9. Posts : 1,049
    Windows 7 Pro 32
       #9

    Excuse me for jumping in but I noticed Kaktussoft was offline.

    Add /i to the findstr command. So your example above would change to:

    ('findstr /m /i body *.idf')
      My Computer


  10. Posts : 10
    Windows 7 ultimate 32bit
    Thread Starter
       #10

    Thanks Tookeri........

    That worked liked a charm!
    I appreciate it,both of you guys!

    Val
      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 20:31.
Find Us