3

I process photos into individual folders, each folder includes subfolders. I want to search and delete all *.jpg files in all the highest level folders.

How could I tell Windows to find and delete all *.jpg in the highest level folder only, but leave all the subfolders untouched?

  • be careful using terms like 'top'. many people imagine a pine tree, where the root is at the top (how stupid is that, roots go underground, not in the air) and the tree grows downward (this is common in CS grads), while others view it as a shrub, with the root on the bottom, growing upwards. – Frank Thomas May 20 '13 at 15:59
0

Try this...

Search Parameters: type:jpg -folderpath:TopLevelFolderName\*\

1

The following in a command line should work:

cd C:\path\to\the\folder
del *.jpg

It should not recurse into subdirectories, based on the documentation. I've not personally tested though, so you might want to run a small test first to be sure. (Always double check when you're not 100% sure and performing a delete of any sort!)

If you do want it to recurse into subdirectories, then use the /S switch:

cd C:\path\to\the\folder
del /S *.jpg 
  • Thanks, I'd like to search for and delete all files in all top-level folders in a directory... but not the subfolders. Directory - folderA - subfolderA,B,C - folderB - subfolderA,B,C - folderC - subfolderA,B,C - folderD - subfolderA,B,C – Scott D May 21 '13 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.