Technical Published

Quick tip: Finding subfolders

When organizing folders you might want to find out if (and which) folder has subfolders. Let's figure out how to find those.

Applications which are running for a while tend to deeply nested file structures over time. Being able to navigate them efficiently helps to clean up and during migrations. So let's take a look how to find out if and which folder has subfolders.

Let's say we have the following folder layout:

data
 disk1
 - subfolder1
 - subfolder2
 disk 2
 - subfolder3
 disk 3

Finding the folders which has subfolders is pretty easy:

find . -mindepth 2 -type d

Adjust the mindepth parameter to your needs. In the given case, it outputs:

./disk2/subfolder3
./disk1/subfolder2
./disk1/subfolder1

Keep reading

Related posts