How extract files from nested folders - is there an app?


  1. Posts : 1,037
    Windows 10 Pro
       #1

    How extract files from nested folders - is there an app?


    I have one primary folder and, under it, are nested folders - perhaps 3 to 5 deep. Is there an easy way to extract the files so that I end up with the primary folder and no subfolders - just all the files?
      My Computer


  2. Posts : 809
    Win10
       #2

    If it's a one-time thing you can go to the primary folder and enter "*" in the search box. That will bring up all the files and folders under the primary. Then you can select just the files and cut+paste them.

    If you need to do this regularly then you can write a batch file/script. Something like
    Code:
    C:\temp>cd primary
    
    C:\temp\primary>for /f "tokens=*" %X in ('dir /b /s /a:d') do copy "%X" .
    (adapted from for /d - Loop through directory - Windows CMD - SS64.com )
      My Computer


  3. Posts : 16,946
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #3

    Nisko,

    I use this batch file. I call it FlatFileCopierToDesktop.bat but you can call it whatever you want.

    Code:
    :: Put this batch file in the highest level folder of the set you want to work through, it will copy all the files to a folder of your choice
    :: Put in your chosen target folder in place of my D:\Desktop\FlatFileCopies.  Choosing a target folder that the batch file has to make is merely how I use this - you could use an existing folder and ditch the line beginning md ...
    :: If you want only certain files, replace (*) with (*.txt) or similar
    Set TargetFolder=D:\Desktop\FlatFileCopies
    md "%TargetFolder%" 
    for /r %%d in (*) do copy "%%d" "%TargetFolder%"
    Pause to check afterwards
    Denis
      My Computer


  4. Posts : 287
    win 10 home
       #4

    Any file manager/exploer with the ability to do a recursive search, that is, explore the files in nested folders, should achieve your goal.

    I personally use XNView, installed, for the right-click context menu recursive (show all files) search. Select all, drag-and-drop to another folder or to the parent folder. There is a portable zip version for a one-time use.
      My Computer


  5. Posts : 1,037
    Windows 10 Pro
    Thread Starter
       #5

    All these solutions are great - thank you very much.


    I tried the first one (use an "*") and it seems to have worked for what I want it for. I'd like to try the others too - but I don't know how to use or insert batch files. By tomorrow, I intend to reply to those posts that require code. If you're willing to guide me a little, I'd like to learn. Thank you!
      My Computer


  6. Posts : 16,946
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    I started learning about batch files by reading this guide - The Command Line in Windows Batch file basics

    I then moved on to Rob van der Woude's guides and examples - Batch files - RobvdW

    But if you are going to sit down and systematically study something, consider studying Powershell instead - it is a structured set of commands & MS regard it as supplanting command window commands & batch files.
    Start with PowerShell Scripting - The Basics - TenForums,
    then PowerShell Scripting - Run a Script from Shortcut - TenForums
    After that, I am not at all sure which one to recommend. You could try downloading & studying Getting Started with PowerShell - Shepard

    Denis
      My Computer


  7. Posts : 1,097
    Windows 10 Home x64 Version 1809 (OS Build 17763.437)
       #7

    Another good place to poke around is https://technet.microsoft.com/en-us/...or=-2147217396
      My Computer


  8. Posts : 1,037
    Windows 10 Pro
    Thread Starter
       #8

    Thanks, folks, for the guidance.
      My Computer


 

  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 16:00.
Find Us




Windows 10 Forums