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
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.
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!
Thanks for the tip! I'll try that out.