• Moving multiple files into their respective folders

    Home » Forums » AskWoody support » Windows » Windows – other » Moving multiple files into their respective folders

    Author
    Topic
    #499306

    Greetings, everyone.

    I have a folder with thousands of files that I have to organize into their own respective folders. I’ve used the command prompt listed here and it’s partially fulfilled what I’ve needed done except when it comes to files that have mildly different naming conventions:

    ABC(A)123_321 PT.1_VER_1
    ABC(A)123_321 PT.1_VER_1A

    The command prompt above would toss the “VER_1A” files into the “VER_1” folder, returning the error “The filename, directory name, or volume label syntax is incorrect” for the “VER_1A” folder itself.

    I’ve tried searching for possible ways to configure the command but my limited understanding of how it functions proved to be insufficient. 🙁

    Therefore, any and all advice on how I could solve the above would be greatly appreciated.

    Cheers!

    Viewing 4 reply threads
    Author
    Replies
    • #1498321

      Open the folder. Hold down the Ctrl key and select any number of files by left clicking on each in turn to highlight it. Right click on any highlighted file and click on copy (you could use cut, but then you’d have no backup if you hit a problem so I would suggest copying the entire folder to a flash drive to act as a back up before starting. You should probably do that anyway.:cool:) This will copy all the highlighted files. Open the new folder, right click and paste your saved files into it.

    • #1498363

      The original copy assumes you want any files that start with the directory name placed in the directory. If you want an exact match we need to know the criteria for matching files with folders.
      Can you provide an example of the files and folders based on your first post? We need to know what bit of the file is OK to match and what bit is allowed to change.

      cheers, Paul

      • #1499063

        @Calimanco
        Touche. A tried and tested solution no doubt but it’s awfully time-consuming and prone to human errors when I’m looking at thousands of files that have to go into a thousand different folders. Point taken though and will keep that in mind for when I’m dealing with an amount less…ridiculous. 😉


        @Paul

        First and foremost, thank you truly for the original copy. You have no idea how much time and effort it saved me for files which have more direct and unique naming conventions.

        My scenario is identical to the original poster’s in the other thread. All the files and folders I’m looking to move are housed within the same directory (F:Databank). Some samples of the files and folders I’m looking at are:

        F:DatabankTAR(FIN)A17995_VER 1
        F:DatabankTAR(FIN)A17995_VER 1A
        F:DatabankTAR(FIN)A17995_VER 1B
        F:DatabankTAR(FIN)A17995_VER 2
        F:DatabankTAR(FIN)A17995_VER 1.pdf
        F:DatabankTAR(FIN)A17995_VER 1.txt
        F:DatabankTAR(FIN)A17995_VER 1A.pdf
        F:DatabankTAR(FIN)A17995_VER 1A.txt
        F:DatabankTAR(FIN)A17995_VER 1B.pdf
        F:DatabankTAR(FIN)A17995_VER 1B.txt
        F:DatabankTAR(FIN)A17995_VER 2.pdf
        F:DatabankTAR(FIN)A17995_VER 2.txt

        What I have to do is to move the .pdf and .txt files to their respective folders. With the command you shared in the other thread, it basically gets 75% of the job done, except for files which have an extended component (e.g. VER 1A & VER 1B). These files get moved into the same folder as it’s root file (e.g. VER 1), essentially leaving their own folders blank and unused.

        Normally, I wouldn’t mind cutting/pasting these runaway files into their intended folders but I have ~2,000 files with these extended components in this current batch.

        As such, I really need a foolproof method to do this so that I don’t have to go through these folders again if a file has been misplaced due to human error…or before I bawl my eyes out scrutinizing each and every file title while herding them into their own pen. 🙁

        Cheers!

    • #1499084

      Stan, I must be a mushroom, in the dark, in your opening, exactly where is the exact copy or xcopy command you are using? I’m an old batchfile dude, somewhere between Beginner and Duffer.

      "Take care of thy backups and thy restores shall take care of thee." Ben Franklin, revisted

    • #1499091

      @RolandJS
      My bad. I just didn’t shine the light very well on what I was doing. The command prompt I’m currently using is by Paul, which he had done for another user in this other thread:

      Code:
      [COLOR=#333333]for /f “tokens=*” %x in (‘dir /ad /b’) do move “%x*.*” “%x”[/COLOR]

      @jwoods
      Many thanks for the recommendation. However, after messing around with it for a while, I believe it doesn’t have a feature to send files into folders.

      It’s compare function though, that I could put to good use when I’m doing some housekeeping to ensure that I don’t accidentally delete files which I have yet to back up. 😀

    • #1499108

      As the only thing that is allowed to change is the extension we can do it very easily.

      Code:
      for /f “tokens=*” %x in (‘dir /ad /b’) do move “%x.*” “%x”

      cheers, Paul

    Viewing 4 reply threads
    Reply To: Moving multiple files into their respective folders

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: