Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file to create folder following the name of specific file then move files  (Read 8414 times)

0 Members and 1 Guest are viewing this topic.

liechie

    Topic Starter


    Greenhorn

    • Experience: Experienced
    • OS: Windows 7

    Hi i'm an imposition specialist. I need to move files that are all present in one folder to folders that are of the file names. formats are (2).pdf and .psd. I need a batch file that will read the file name, make a folder of part of that file name and move all files that start with that file name into that folder regardless the extension.

    For example, if I have 9 files named as

    111111_1_abcde - pdf
    111111_001_Cut - psd
    111111_1_Bar - pdf

    222222_2_abcde - pdf
    222222_002_Cut - psd
    222222_2_Bar - pdf

    333333_ 3_2S_100 - pdf
    333333_3_Barcode - psd
    333333_A_-003_Cut - pdf

    I need a batch file that will make folders 111111, 222222 and 333333 and move all the respective files into the respective folders. So, files 111111_1_abcde - pdf, 111111_001_Cut - psd, 111111_1_Bar - pdf will be in folder named after the fiest pdf w/c is files 111111_1_abcde - pdf that doesn't have extension of Bar.

    I'm researching every now and then to figure this out that I just came up making 1 folder for the example mentioned above and not 3. I've been to stock overflow and other sites that helps in coding but ends up always a mistake.

    For this i tried these programs with the basic language that i have about dos programming and using examples from other thread is this website

    http://www.computerhope.com/forum/index.php?topic=152980.0

    I'm hoping that some script geek will have a lil time for this. It will be very appreciated

    thanks in advance!

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    I am not understanding what you want the folder names to be with your given example because this statement confuses me.
    Quote
    So, files 111111_1_abcde - pdf, 111111_001_Cut - psd, 111111_1_Bar - pdf will be in folder named after the fiest pdf w/c is files 111111_1_abcde - pdf that doesn't have extension of Bar.

    liechie

      Topic Starter


      Greenhorn

      • Experience: Experienced
      • OS: Windows 7
      I'll make a more understandable example, sorry for typography error and confusing

      111111_1_abcde - pdf
      111111_001_Cut - psd
      111111_1_Bar - pdf

      created folder name: 111111_1_abcde

      thanks a lot



      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      For example, if I have 9 files named as

      111111_1_abcde - pdf
      111111_001_Cut - psd
      111111_1_Bar - pdf

      222222_2_abcde - pdf
      222222_002_Cut - psd
      222222_2_Bar - pdf

      333333_ 3_2S_100 - pdf
      333333_3_Barcode - psd
      333333_A_-003_Cut - pdf
      So these files have no file extension?

      I am also confused on which file from the 333333 set is supposed to be used for the folder name?

      liechie

        Topic Starter


        Greenhorn

        • Experience: Experienced
        • OS: Windows 7
        folder name: 111111_1_abcde
        111111_1_abcde - pdf
        111111_001_Cut - psd
        111111_1_Bar - pdf

        folder name: 222222_2_abcde
        222222_2_abcde - pdf
        222222_002_Cut - psd
        222222_2_Bar - pdf

        folder name: 333333_ 3_2S_100
        333333_ 3_2S_100 - pdf
        333333_3_Barcode - psd
        333333_A_-003_Cut - pdf

        they are pdf and a psd. each folder will have 2 pdf and 1 psd

        liechie

          Topic Starter


          Greenhorn

          • Experience: Experienced
          • OS: Windows 7
          here's another example

          folder name will be: 306113_A_3

          306113_A_3
          306113_A_BAR
          306113_003_Cut

          thank a lot!

          Squashman



            Specialist
          • Thanked: 134
          • Experience: Experienced
          • OS: Other
          they are pdf and a psd. each folder will have 2 pdf and 1 psd
          Then why are you providing file name examples with a space dash space for the file extension.

          This seems to make more sense to me.
          333333_ 3_2S_100.pdf
          333333_3_Barcode.psd
          333333_A_-003_Cut.pdf

          liechie

            Topic Starter


            Greenhorn

            • Experience: Experienced
            • OS: Windows 7
            correct, they are just the file format

            I just use dash space to indicate that it's a pdf/psd

            names will be just

            111111_1_abcde
            111111_001_Cut
            111111_1_Bar

            222222_2_abcde
            222222_002_Cut
            222222_2_Bar

            333333_ 3_2S_100
            333333_3_Barcode
            333333_A_-003_Cut

            306113_A_3
            306113_A_BAR
            306113_003_Cut

            hope that this will help

            thanks again

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            correct, they are just the file format

            I just use dash space to indicate that it's a pdf/psd

            names will be just

            111111_1_abcde
            111111_001_Cut
            111111_1_Bar

            222222_2_abcde
            222222_002_Cut
            222222_2_Bar

            333333_ 3_2S_100
            333333_3_Barcode
            333333_A_-003_Cut

            306113_A_3
            306113_A_BAR
            306113_003_Cut

            hope that this will help

            thanks again
            So now the file names have no extension?

            liechie

              Topic Starter


              Greenhorn

              • Experience: Experienced
              • OS: Windows 7
              yes they do not have, I just used that dash space to indicate its file format

              Squashman



                Specialist
              • Thanked: 134
              • Experience: Experienced
              • OS: Other
              yes they do not have, I just used that dash space to indicate its file format
              Are you using Windows? Windows can only identify the file type and open files based on the file extension. It will not show the correct icon for a file without it.

              liechie

                Topic Starter


                Greenhorn

                • Experience: Experienced
                • OS: Windows 7
                sorry I made a confusion again,

                these are the file formats

                333333_ 3_2S_100.pdf
                333333_3_Barcode.psd
                333333_A_-003_Cut.pdf

                306113_A_3.pdf
                306113_A_BAR.psd
                306113_003_Cut.pdf

                sorry for the late reply




                liechie

                  Topic Starter


                  Greenhorn

                  • Experience: Experienced
                  • OS: Windows 7
                  Folder arrangement using batch file
                  « Reply #12 on: January 24, 2017, 08:54:42 AM »
                  Hi Everyone,

                  Im not that good is scripting and It will be very appreciated if someone will spend a minute with this on

                  is it possible for a batch script to open a folder and arranged like this




                  thanks!

                  Allan

                  • Moderator

                  • Mastermind
                  • Thanked: 1260
                  • Experience: Guru
                  • OS: Windows 10
                  Please don't start multiple threads for the same question. I merged the two threads into this one.

                  patio

                  • Moderator


                  • Genius
                  • Maud' Dib
                  • Thanked: 1769
                    • Yes
                  • Experience: Beginner
                  • OS: Windows 7
                  Also the image is impossible to view...
                  " Anyone who goes to a psychiatrist should have his head examined. "