How can I use tree to ignore a specific folder while listing files?

0
4
Asked By CleverTurtle27 On

I'm trying to use the 'tree' command to list all files in a folder and its sub-folders, but I want to exclude one specific folder called 'Document Scans'. My goal is to scan everything in '/media/me/Documents/' but ignore '/media/me/Documents/Document Scans/'. I've been using this command:

`tree -sh /media/me/Documents/* -I /media/me/Documents/Document Scans/ > /home/me/TreeList.txt`

However, it doesn't seem to exclude the 'Document Scans' folder, and I'm not sure what I'm doing wrong. Any advice?

2 Answers

Answered By TechieHawk45 On

It looks like you have a couple of issues here. First, when you use `/*`, you're including everything under the '/Documents/' folder, which also means 'Document Scans'. So the '-I' option won't filter it out since it's part of the initial argument.

You should just use:

`tree -sh /media/me/Documents -I 'Document Scans/' > /home/me/TreeList.txt`

This way, you're listing everything in '/Documents/' and explicitly telling it to ignore that specific folder.

Answered By CodingNinja89 On

You might want to simplify your pattern match. Try running:

`tree -sh /media/me/Documents -I Document Scans`

This should effectively ignore the 'Document Scans' folder as needed!

CleverTurtle27 -

Thanks for the tip! I'll try that out.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.