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?

1
  • 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. May 20, 2013 at 15:59

2 Answers 2

0

Try this...

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

1
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 
1
  • 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, 2013 at 4:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .