How to add containing folders to collection of files

Page 3 of 4 FirstFirst 1234 LastLast

  1. Posts : 869
    Windows 10 Professional x64 21H2
       #21



    - - - Updated - - -

    Paul Black said:
    It was just strange that you were also thinking of a way to achieve this task.
    Thank you, Paul. I find that to be a compliment.
      My Computers


  2. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #22

    Slightly improved code . . .

    This batch script creates a folder for each filename in the directory that the batch script resides in and then populates [ moves ] them with the files accordingly. The folders names will be a mirror image of the filenames themselves, excluding the suffix.

    WARNING: Setup a test directory directory that includes a selection of filenames FIRST and then run the batch script to ensure that the results are correct and as expected.

    Code:
    @echo off
    title Files To Folders - Written by Paul Black.
    mode con: cols=60 lines=7 & color 17
    set count=-1
    echo. & echo  Processing . . .
    for %%j in (*) do set /A Count +=1
    for %%i in (*) do (
      if not "%%~ni" == "Files_To_Folders" (
        md "%%~ni" && move "%%~i" "%%~ni" >nul
      )
    )
    echo. & echo  Created and populated %Count% folders successfully!
    echo. & echo ^>Press ANY key to EXIT . . . & pause >nul
    Last edited by Paul Black; 03 Jul 2020 at 12:10.
      My Computer


  3. Posts : 869
    Windows 10 Professional x64 21H2
       #23

    Good morning Paul. It's 7:30 AM and having my morning coffee. I ran a side by side comparison of the two codes and the only change I see is the blue CMD. Slightly Improved

    - - - Updated - - -

    And what dose this change of code do exactly? See the image.
    Attached Thumbnails Attached Thumbnails How to add containing folders to collection of files-old-code.png   How to add containing folders to collection of files-slightly-improved-code-.png   How to add containing folders to collection of files-code-compare.png  
      My Computers


  4. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #24

    Hello @Lance1,

    Lance1 said:
    Good morning Paul. It's 7:30 AM and having my morning coffee. I ran a side by side comparison of the two codes and the only change I see is the blue CMD. Slightly Improved

    - - - Updated - - -

    And what dose this change of code do exactly?
    Nothing really, I just made it a bit more visual.
      My Computer


  5. Posts : 869
    Windows 10 Professional x64 21H2
       #25

    Paul Black said:
    Hello @Lance1,


    Nothing really, I just made it a bit more visual.
    So the; mode con: cols=60 lines=7 & color 17 made the CMD blue? I find this interesting. Is 62 too late to start learning code?
      My Computers


  6. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #26

    Hello Lance1,

    Lance1 said:
    So the; mode con: cols=60 lines=7 & color 17 made the CMD blue? I find this interesting. Is 62 too late to start learning code?
    You are NEVER too late to learn!

    Type this in a cmd prompt and press <ENTER> . . .

    Code:
    color /?
    I hope this helps!
      My Computer


  7. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #27

    Hello @Fundeby,

    Fundeby said:
    I have several thousand files that I want put into individual folders of the same name. Does anyone know of a batch method for this?
    Have you had a chance to look at and test the code I wrote yet?
      My Computer


  8. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #28

    Hello @Lance1,

    I will put something together today for your other batch script request!
      My Computer


  9. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #29

    Hello @Lance1,

    WARNING: Setup a test directory that includes a selection of suffixes FIRST and then run the batch script to ensure that the results are correct and as expected.

    Here is the file => Code moved further down the thread.

    Please let me know how you get on!
    Last edited by Paul Black; 03 Jul 2020 at 12:40.
      My Computer


  10. Posts : 869
    Windows 10 Professional x64 21H2
       #30

    Lance1 said:
    Can you write the .bat to sort by file extension? I noted that the two .mp3 file had separate folders. As if it were file extension they would be in the same folder.
    Paul Black said:
    Hello @Lance1,
    The code wouldn't know what to call the folder!
    I had faith that you had the skills and you did it! Some did not get sorted as they not in the script. Well done and Thank You Paul. Before and After Pics.
    Attached Thumbnails Attached Thumbnails How to add containing folders to collection of files-1.png   How to add containing folders to collection of files-2.png  
      My Computers


 

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

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




Windows 10 Forums