Need To Do Fancy Windows File Manipulation

AI Thread Summary
To delete all .jpg files from multiple folders in Windows without manually handling each one, the command line offers an efficient solution. Navigate to the parent folder containing all the subfolders and use the command "erase /s *.jpg" to remove all .jpg files recursively. For added caution, the "/p" option can be used to prompt for confirmation before each deletion. Alternatively, Windows Explorer can be used to search for .jpg files, allowing users to select and delete them through the interface, with the option to recover files from the Recycle Bin if needed. Another method involves using robocopy to move .jpg files to a different directory before deletion, ensuring no files are lost. PowerShell also provides a move command for similar purposes. Users have reported significant space recovery by managing their files effectively, highlighting the importance of organizing and deleting unnecessary media files.
Hornbein
Gold Member
Messages
3,388
Reaction score
2,746
I have about one hundred folders. Each folder has both .jpg and .mp4 files. I want to delete all the .jpgs but not the .mp4s. I don't want to do each folder by hand. Does anyone know the Windows/DOS command that will do this. Just moving the files depending on file type is enough.
 
Computer science news on Phys.org
Please be very careful with this, there is no safety net to catch you.

If all the 100 folders are inside folder x then open a command window and CD into folder x and then

erase /p /s *.jpg

That /p is going to prompt you to ask whether you want each file erased or not. I would suggest looking carefully at the name of the file it is about to erase and answering no to that question again and again and again until it is done. If every one of those file names was correct and it didn't end up asking you if you wanted to erase a very important file that you wanted to keep then you can do

erase /s *.jpg

and let it go.

All this is based on reading

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/erase

The /s will have it look into the x folder, erase all jpg files there and then go into every folder inside x and do the same and go into every folder in every folder inside x, etc.

Ah, there is another way.

Windows Explorer is what you may use when you are trying to find files. You can use that to move to your x folder and then use the search box that is in the upper right corner to look for all jpg files in x and below x. That will take a while to complete. That should show you a list of every jpg file in those folders. Then you can carefully look through all the buttons across the top of the window and find a button that will Select All of those search results. That should highlight all the 100 plus jpg files. Then more looking through the buttons and you should find a red X with a Delete label under it. Tapping on that X should move all those highlighted file names to the Recycle Bin. (There are settings to make anything deleted to be instantly permanently deleted, presumably you have not set that. There are also things like if you do this from an inserted thumb drive that the deleted files do not go to the recycle bin on the thumb drive, because there isn't one, presumably you are not doing this from a thumb drive. After all those cautions... (Can you tell I don't trust not losing important files?) Then you are free to close Windows Explorer, open the Recycle Bin, see that all the appropriate files are there and then empty the bin.

Please post a message when you are done and let everyone know how it worked for you
 
Last edited:
Can you use robocopy?

robocopy c:\old c:\new /mir
robocopy c:\old c:\new /s *.jpg
 
Rather than a delete, I suggest a move operation so that the files are not lost. That way if you ever need them again, you have them, but they are in a different folder so no longer in the way.

The Windows powershell move command will do this. Here's a good place in the Microsoft Learning Center to get the syntax and see an example:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/move-item?view=powershell-7.3

You want to look for Example 4. Here's part of it
1669437917199.png
 
  • Like
Likes Wrichik Basu
That worked like a charm. I had well over ten thousand photos each from three to nine megabytes in size. I had them all backed up on an external hard drive. I never look at them. I resized them all, reducing to about 4% of the size of the original, moved the original jpgs to another directory with Powershell, then deleted that directory. Recovered about 60 gigabytes.

Surprising to me is that I still have 60 gig of mp4 videos. I would never have imagined it was anywhere near that. I seldom make them, or at least so I thought. I never watch them. I guess they will be next to get the axe when the SSD fills up again.
 
  • Like
Likes jack action and phinds
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
i am customizing a Linux distro [arch] into love os which I am building to impress my crush. I had an idea to integrate an ai model into the Linux system so it can speak like me but romantically. but I don't know what or how to do. I don't know the basic concept of Linux but yet I am customizing my os purely relying on chat gpt and perplexity. when i ask chat gpt about this it said to fine tune an ai model and integrate to the Linux distro and my friend said for the data to be fed to the ai...
Back
Top