Windows 10: Delete everything but picture files from a directory structure?

  1.    19 Sep 2016 #1

    Delete everything but picture files from a directory structure?


    Got an odd request, anyway to delete everything but picture files from a directory structure ?
      My System SpecsSystem Spec

  2.    19 Sep 2016 #2

    ZippyDSMlee said: View Post
    Got an odd request, anyway to delete everything but picture files from a directory structure ?
    Select all picture files in explorer, right click and select properties. Mark them as hidden, delete remaining files, and then unhide the files and remove hidden attribute.

    You may have to do this by directory.
      My System SpecsSystem Spec

  3.    19 Sep 2016 #3

    cereberus said: View Post
    Select all picture files in explorer, right click and select properties. Mark them as hidden, delete remaining files, and then unhide the files and remove hidden attribute.

    You may have to do this by directory.
    Mmmmmm command line should be able to select a wild cards, tho I am unsure if you can string them together. Not sure if you can exempt this and delete that and keep folders but delete empty folders LOL
      My System SpecsSystem Spec

  4.    19 Sep 2016 #4

    Hi, if this is only required once, and there aren't too many subfolders, a relatively simple way might be to use an image viewer. That automatically picks out all image files of types it supports.

    View the folder in the image viewer, mark all as hidden. (Borrowing @Cerberus idea)
    Delete the remainder in file explorer, unhide the images.

    Repeat for all other folders.

    I'm not sure if you're looking for a script to do this repeatedly.
    If so, you could possibly do that with a viewer you can use from the command line e.g.
    PictView - image viewers and converters
    - but I can't see what the command line options are for that!
      My System SpecsSystem Spec

  5. MilesAhead's Avatar
    Posts : 716
    Host W8.0 x64 Guest W10 x86
       19 Sep 2016 #5

    Code:
    Loop, x:\RootFolder\*.*, 0,1 ;  x = drive letter - 1 = search subfolders
    {
        if (A_LoopFileDir = A_WinDir)      
          continue
    
        if A_LoopFileExt not in bmp,gif,jpg,png ; add other image extensions as needed
          FileDelete, %A_LoopFileLongPath%
    }

    You can download AutoHotkey free programming tools from http://www.autohotkey.com


    It may be a good idea to build in a sanity check to make sure the root folder does not contain the Windows folder or any folder with other files that should not be deleted. The code I pasted is just a quickie starting point. On the AHK site you can download tools including an IDE that can wrap the script and interpreter into an exe so that the program will run on machines that do not have AHK installed.


    Enjoy

    Edit: I added an If statement to skip to the next loop if the current folder is the Windows folder as example how it is done. The forums for autohotkey are populated with regular posters who enjoy helping people with their scripts. So just visit the "ask for help" forum there for enahancements.
      My System SpecsSystem Spec

  6.    19 Sep 2016 #6

    MilesAhead said: View Post
    Code:
    Loop, x:\RootFolder\*.*, 0,1 ;  x = drive letter - 1 = search subfolders
    {
        if (A_LoopFileDir = A_WinDir)      
          continue
    
        if A_LoopFileExt not in bmp,gif,jpg,png ; add other image extensions as needed
          FileDelete, %A_LoopFileLongPath%
    }

    You can download AutoHotkey free programming tools from http://www.autohotkey.com


    It may be a good idea to build in a sanity check to make sure the root folder does not contain the Windows folder or any folder with other files that should not be deleted. The code I pasted is just a quickie starting point. On the AHK site you can download tools including an IDE that can wrap the script and interpreter into an exe so that the program will run on machines that do not have AHK installed.


    Enjoy

    Edit: I added an If statement to skip to the next loop if the current folder is the Windows folder as example how it is done. The forums for autohotkey are populated with regular posters who enjoy helping people with their scripts. So just visit the "ask for help" forum there for enahancements.
    I'll give it a go, its mainly all just a recovery of a WinXP hard drive, they want the pictures on CD's(5 or 6 in all I think) of all things, so I need to pair it down some. I think one I get down to pictures I will remove the 0-10KB ones then check and make sure the rest are half viewable. Not having a bit of luck with picture repair programs or hex editing the headers. Blah oh well some are there and working at least.

    Recovery of the hard drive on a USB hard drive(secondary documents and stuff they can get to if they want), plus pictures on CD plus all pictures on a DVD(dvds are nice I like dvds LOL).
      My System SpecsSystem Spec

  7. MilesAhead's Avatar
    Posts : 716
    Host W8.0 x64 Guest W10 x86
       19 Sep 2016 #7

    ZippyDSMlee said: View Post
    I'll give it a go, its mainly all just a recovery of a WinXP hard drive, they want the pictures on CD's
    ...
    Ah, in that case I feel much better. No worries about hosing a running system. AHK syntax can be weird on some of the older built in functions. But it can be great for doing file stuff simply. I wrote a utility to delete every index.dat file on the system drive in 7 lines of code. You could do the same thing with a command line batch but the AHK runs much smoother.
      My System SpecsSystem Spec


 

Related Threads
One me time! After installing the Anniversary Update I cannot delete the "windows.old" folder. I have gone through the routine of System Settings>Storage>This PC>Temporary Files and checked the Previous Version of Windows. That did the job and...
How to Delete Recent Account Picture History in Windows 10 You can choose an account picture in Windows 10 to be associated with your user account (local and Microsoft) that you will see whenever you sign in to your PC and on your Start menu. You...
As a keen flickr member I have a lot of photographs on my computer. These are all neatly allocated to different files, depending upon a variety of variables. So far....all is well. Yesterday my neighbour kindly upgraded me to Windows 10. ...
Let me explain. I upgraded to windows 10 flawlessly. I want to change my .txt document to open with Notepad++ for coding. But every time I click properties>change Nothing pops up. Does anybody know a workaround or a fix? I need to get to work.:cry:...
25771 I just noticed some change in the Get Windows 10 app..
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 07:10.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums