Mac App Subdirectories Contents

  

If the weird name throws you, 'grep' is an acronym for 'general regular expression

How to find files via the OS X Terminal. If you need to search for files in OS X, one option it is to use the OS X Terminal application and some of its services.


program'. If that doesn't help, it's probably because you're wondering what a
regular expression ('re' or 'regex') is. Basically, it's a pattern used to describe
a string of characters, and if you want to know aaaaaaall about them, I highly
recommend reading Mastering Regular Expressions by Jeffrey Friedl and
published by Unix über-publisher O'Reilly & Associates.

Regexes (regices, regexen, ...the pluralization is a matter of debate) are an extremely
useful tool for any kind of text processing. Searching for patterns with grep is
most people's first exposure to them, as like the article says, you can use them to search
for a literal pattern within any number of text files on your computer. The cool thing is
that it doesn't have to be a literal pattern, but can be as complex as you'd like.

The key to this is understanding that certain characters are 'metacharacters', which have
special meaning for the regex-using program. For example, a plus character (+) tells the
program to match one or more instances of whatever immediately precedes it, while parentheses
serve to treat whatever is contained as a unit. Thus, 'ha+' matches 'ha', but it also matches
'haa' and 'haaaaaaaaaaa', but not 'hahaha'. If you want to match the word 'ha', you can use
'(ha)+' to match one or more instances of it, such as 'hahaha' and 'hahahahahahahahaha'.
Using a vertical bar allows alternate matching, so '(ha|ho)+' matches 'hohoho', 'hahaha', and
'hahohahohohohaha'. Etc.

There are many of these metacharacters to keep in mind. Inside brackets ([]), a carat (^)
means that you don't want to match whatever follows inside the brackets. For Magritte
fans, '[^(a cigar)]' matches any text that is not 'a cigar'. The rest of the time, the carat tells
the program to match only at the beginning of a line, while a dollar sign ($) matches only at
the end. Therefore, '^everything$' matches the word 'everything' only when it is on a line all
by itself and '^[^(anything else)]' matches all lines that do not begin with 'anything else'.

The period (.) matches any character at all, and the asterisk (*) matches zero or more times.
Compare this to the plus, which matches one or more times -- a subtle but important
difference. A lot of regular expressions look for '.*', which is zero or more of anything
(that is, anything at all). This is useful when searching for two things that might or might
not have anything else (that you probably don't care about) between them: 'foo.*bar' will match
on 'foobar', 'foo bar' & 'foo boo a wop bop a lop bam boo bar'. Changing the previous example
to a plus, 'foo.+bar', requires that anything -- come between foo and bar, but it doesn't matter
what, so 'foobar' doesn't match but the other two examples given do match.

App

For details, try the man pages -- 'man grep'. There are a lot of different versions of the
program, so details may vary. All of this should be valid for OSX though.

Confusing? Maybe, but regular expressions aren't that bad when you get used to them, and
they can be a very useful tool to take advantage of it you know what you're doing. An example.

Let's say you have an website stored on your computer as a series of html documents.
As a cutting edge developer, you've seen the CSS light and want to delete all the
tags wherever they're just saying e.g. face='sans-serif' &/or size='12', because the
stylesheet can now do that for you. On the other hand, it's possible that the patterns
'face='sans-serif' or 'size='12' could show up in normal text (though admittedly
that's unlikely). In fact, what you really want to know is wherever those patterns show up in
a font tag, but you don't care about anywhere else that they might appear. Here's one way to
find that pattern:

This does a number of things. The -i tells grep to ignore case (otherwise it's case sensitive,
and won't match 'FONT' if you're looking for 'font' or 'Font'). The -r tells it to recursively
descend through the directories from wherever the command starts -- in this case, all htm and
html files in the current directory. Everything in single quotes is the pattern we're matching.
We tell grep to match on any text that starts with ' (thus staying within the font tag), and then either the face or
size definition that we're interested in. The one glitch here is that line breaks can break
things, though there are various ways around that. Finding them is left as the proverbial
exercise for the reader. :)

The next question is, what do you want to do with this information you've come up with?
Presumably you want to edit those files in order to fix them, right? With that in mind, maybe
it would be useful to just make a list of matches. Grep normally outputs all the lines that
match the pattern, but if you just want the filenames, use the -l switch. If you want to save
the results into a file, redirect the output of the command accordingly. With those changes,
we now have:

Great. But we can do better still. If you are comforable with the vi editor, you can call vi
with that command directly. The trick is to wrap the command in backticks (`). This is a cool
little Unix trick that runs the contained command & returns the result for whatever you want
to do with it. Thus you can simply put this command:

The result of this command, as far as your tcsh shell is concerned, is something along the lines
of

etc. The beautiful thing here is that if you quit vi & re-run the command later, it will be
able to effectively 'pick up where you left off', since files you've already edited will
presumably no longer match the grep command.

And if you want to get really ambitious, you can use these techniques in ways that
allow you to do all your editing directly from the command line, without having to go into an
interactive editor such as vi or emacs or whatever. If you make it this far in your experiments,
then the next step is to learn to filter the results of a match and process the filtered data
in some way, using tools such as sed, awk, and perl. Using these tools, you can find all
instances of the pattern in question, break it down however you like, substitute or shuffle the
parts around however you like, and then build it all back up again. This is fun stuff! By this
point, you're getting pretty heavily into Unix arcana, and the best book that I've seen about
these tricks is O'Reilly's Unix Power Tools, by various authors. If you really want to leverage
the power of the tools that all Unixes come with, including OSX, then this is a great place to
both start & end up. There's plenty of material in there to keep you busy for months & years...

Whether you need to do so for yourself or for someone else, there is sometimes a need to create a listing of the contents of a particular directory, set of directories, or a whole drive. With the size of hard drives today reaching multiple Terabytes, keeping track of all the stored files would be quite useful. It’s quite easy to find out what files are taking up the most drive space but it’s also handy to know what files are stored where.

There are very simple ways of getting a list of files in a folder without external software. One option is using the Windows command “Dir [folder] > File.txt” from the Command Prompt. However, messing around with console commands is not to everyone’s liking and Dir is also quite limited. Here’s a selection of 10 free tools to save or print out content lists of the files inside your folders including to plain text file, an Excel spreadsheet, or an HTML document. All tools were tested in Windows 10 and 7.

1. FileListCreator

What makes FileListCreator a potentially very useful program is the number of available options in specific areas. It has several different file formats you can save to, including text file, HTML page, comma separated value file (CSV), Excel spreadsheet, and even image files (PNG, JPG, or BMP). FileListCreator has a portable version, is multi-platform, and free to use (donations are welcomed by the author).

You can add multiple files and folders from different directories or drives by simply using the buttons or dropping them onto the window. The lower pane in the interface is a live preview of the output format which you can copy to the clipboard or save. There’s a huge amount of columns you can add to the list including specific columns for images, audio files, video files, text files, documents, attributes, and checksums. Limited output format options such as fonts and colors are found in the Settings.

Download FileListCreator

2. Snap2HTML

Snap2HTML is a portable tool that is able to generate a single HTML file that lists all folders and files from a predefined root folder. It’s the one tool in this list we actually use ourselves to make content lists of external drives. What makes Snap2HTML so useful is it creates the most functional and visually appealing HTML file from any tool we’ve seen. It’s very easy to navigate through the list of files and folders in your browser.

The configuration options are few with tick boxes to include hidden or system files. The Link files option turns file entries into clickable links so you can execute a file directly from the HTML page. Drives or folders are searched recursively. The HTML page looks and behaves a lot like Windows Explorer complete with an expandable tree view down the left and a search option. You can edit the template.html file yourself if you know some CSS. Snap2HTML has command line options for use with Command Prompt and batch files.

Download Snap2HTML

3. DirLister v2

DirLister is a tool that we have talked about before. The original from back in 2005 is available on the developer’s website which doesn’t have a .NET 4.6 requirement. The newer version 2 currently in beta is portable and more feature rich than the old version. One improvement is the ability to add multiple drives or folders to the list at once. Use the “Select folder” button or simply drop a folder onto the window.

In addition to HTML and plain text files, you have the option to save as a CSV file, an XML file, a JSON file, or a markdown file. Multiple output formats can be selected at once. There’s also a filter where you can add normal wildcards (like *.jpg) or Regex if you know how to use it. Optional Explorer integration makes it easy to create a file list from the right click context menu. The HTML page DirLister v2 creates is good and probably only second to Snap2HTML.

Download DirLister v2

4. Arclab Dir2HTML

Dir2HTML is a tool that used to be freeware but Arclab took the program full shareware back in 2013/2014. However, we found the last freeware version from 2011 and look at that here as it still works fine in Windows 10. While it might not have as many features as the latest paid version, the old free version of Dir2HTML has a number of useful options to aid in the creation and customization of the HTML index file.

It supports recursive folder indexing, a simple file mask, creating a sub-section for each subfolder, excluding hidden files and folders, including size and date, and many other options. The right side of the window allows you to tailor the output HTML file visually and you can add a customized title, alter the font sizes, colors, and resize different areas of the output. Many of the options can be left alone if the standard layout is acceptable.

Download Arclab Dir2HTML

5. Karen’s Directory Printer

Directory Printer has been a popular tool for several years for printing and saving file and folder lists. This is because there’s a lot of options you can configure to get the output to your liking. Files have 15 pieces of information that can be displayed including names, dates, sizes, attributes, and checksums. Also included is a file mask filter that already has five format presets built-in for images, music, documents, etc.

There are various save options for hidden and system files, sorting, and what to include/exclude. The separate Print and “Save to Disk” tabs have a few different options to allow you to set different output formatting. There’s a right click context menu function in the Settings tab. Sadly, the only truly useful output file format is a text file. You can extract the setup installer with 7-Zip to create a portable program.

Download Karen’s Directory Printer

12Next › View All

You might also like:

2 Tools to List Files Protected by System File Checker (SFC)10 Free Ways to Download All Files From a Folder on a Website or FTP5 Tools To Extract Icons from EXE files and Save As Images5 Tools to Delete or Replace Multiple Lines for All Files in a Folder8 Free Portable File Managers for Quicker File Operations

Any ideas of Android version of this kind of thing?

Reply
J.C.5 months ago

I’ve been looking for years. No. No Android app. There should be! The only solution is to use dir2html on a Windows machine and connect it to the phone or tablet.

Reply

Is there a program that includes all possible fields? Length for example?

Reply
Kannan7 months ago

The Dir List and Print (#4 in the list above) prints a lot of fields in the free version, with a more complete list of properties which are available only in the purchased version

Reply

Directory List & Print is the best but the free version is limited: No filters.
Karen’s is ok but lacks of preview and looks old.
FileListCreator is better and free as well.

Reply
TheStarman9 months ago

Mac App Subdirectories Contents Permissions

The comments; including your own, say there is supposed to be a utility here called “DriveZ”…
So where is it?

Reply

If you look carefully you’ll see some nice black buttons that take you to page 2 where DriveZ is….;)

Reply
M J10 months ago

KRK’s DirLister (2.37) free edition only allows HTML saves.

Reply

“Dir2Html is a tool which is free for personal and commercial use”

How? When I use it it changes every second entry to “TEST-VERSION” unless I pay.

How is that free???

Reply
HAL9000 Author1 year ago

Because when the article was written, Dir2HTML was freeware, you can even see the title bar in the screenshot say “freeware”. Arclab have since taken the program full shareware.

I’ve tracked down the last freeware version and we now link to that instead.

Reply

DriveZ is so simple and exactly what I was looking for. You don’t need to edit the output again to, say, delete the extensions, file sizes or information etc..

Only the filenames and it’s directly on the clipboard. Just ready to use in one click. Just have a try if you’re looking for such a simple thing..

(Others are not bad too (JR DirPrinter, Dirlister) but you need to clean information etc.. when compared)

Important: When I downloaded DriveZ using the link here, it asked for password for the zip file and it was looking a bit suspicious (v. 1044). So I searched and downloaded from somewhere else (v. 1.0.19)

Reply
HAL9000 Author1 year ago

The DriveZ download is hosted on our own server. We have to password selected files like DriveZ because they produce false positive alerts in some antivirus software and online services like Virustotal. If we don’t do that, just a few files can cause our entire server to be marked by an antivirus vendor as unsafe or malicious.

If you upload your 1.0.19 file to Virustotal, you’ll see that it is classed as malicious by at least one AV service.

Reply

Thank you.

So what’s the password for the downloaded zip files? ( I’d tried blank (enter) but didn’t work.. )

Reply
HAL9000 Author1 year ago

The password is listed on the download page.

Reply

Karen’s Directory Printer let’s you save output as a tsv file (tab separated values) which can be read by Excel

Reply
Carl2 years ago

I have always like Directory Lister v0.9.1 by krksoft.com. There are portable versions online BTW. It looks like there is a newer paid/shareware version but v0.9.1 as of 2006 works fine on Windows 7 however I have not tried any newer version of windows.

It has all the options I need to configure the output and the output can be previewed, modified, previewed and saved or copied to clipboard in text, html or csv formats. It does everything I require, nothing more or less.

Reply

I’m using YourDir, which doesn’t have so many fancy options like the above, but is really easy and saves to either CSV or creates an image file, which I’m using a lot.

Reply
xaris3 years ago

There is another way, open elevated cmd and give the command dir > filelist.txt
Open the file filelist.txt with notepad and print it :D

Reply

You can use and dir/s > filelist.txt command also :)

Reply
MikeG3 years ago

And you can open the file in word when you are done :)

Thanks for the refresher… I miss the DOS days…

Reply

Will any of these suggestions work with Win 10?

Reply
Achitophel3 years ago

Directory List and Print is the only one for me. THE single clincher is its ability to output to Word. I’ve used it to produce lists, tables of contents, indices of hundreds of separate music, image, video files and folders which would have taken years to produce manually and which can be printed. And once in Word, editing is easy – using find and replace to produce a style uniformity. It makes the rest look amateur.

Reply

Thanks for the helpful reviews. @ A King: Nobody is interested in your self-serving propaganda. A PC user has the right to control their own machine, including software made freely available for it,

Reply
Alex3 years ago

Snap2HTML is the BEST! It does exactly what I was looking for and I spent quite a bit of time searching! So happy I found it!

Reply

Dir2Html is no longer free. :(

Reply
randomperson4 years ago

I agree with anyone who says that Snap2HTML is the best! the most important thing about it is that it’s FREE so you don’t have to waste your time for finding a working keygen or patch unlike Dir2HTML(spent 1 hour trying to find a working keygen but nothing) and it has a file explorer alike GUI so you won’t get lost easily while navigating huge database

Reply

Stealing software is a crime

Reply
Crantor3 years ago

So informative ¬¬

Reply

This was e-learning for me. Learnt something new

Reply
Rodrigo4 years ago

I’ve tested all of them and the Snap2HTML was the best for me. Its design is exactly what I was needing.
The DIR2HTML and ArcLab are good options too but for what I needed, the Snap2HTML is the first one.

Reply

DirLister works in a test install, but unlike stated in Raymond’s mini-review (thank you) I was unable to get a listing that included folder names without an unwanted recursive listing. Maybe folder names do list with recursion, but I didn’t have time to try that, and it still wouldn’t help me. Also file sizes is one of several future features not implemented after years of version 1.0, but the author said he would have to need these features before implementing them.

Reply
JRC Sarma4 years ago

I have used SNAP2HTML.
It is indeed a great tool and creates HTML file of the directory in a whisker and handy for the web designers. It has built-in option to search the directory too.
I used it for creating a directory containing nearly 4 TB of Files in thousands of sub-directories. It is simply an awesome tool with clean interface and easy to use.
Special thanks to the Mr. Dan, the developer of SNAP2HTML.

Reply

Great app,

thanks to the Mr. Dan, the developer and you too,

and this article. <3

Reply
Gabriel5 years ago

The one I’ve been using for years is Rep-Listing 3.0 (Jean-Pierre Aigron, 2004) ; apart from a few minor bugs and quirks (incorrect file sizes above 2GB, annoying question asked every time the program is opened about « margins set outside the printable area ») it’s complete, fast and efficient. The listings are clear and include the file sizes in bytes written as continuous numbers (i.e. with no spaces, for instance a VOB file will be : 1073709056), which was the feature I was looking for back then. I wanted to have a list of the contents for each one of my hundreds of archived CD/DVDs, with the accurate file sizes, so that I could quickly verify if a file I was about to download was already there somewhere, only by typing its size in Windows XP’s search panel (dearly missed on later iterations), searching inside the directory containing all the listings for a given category of content (then if I wanted to be sure I could take the corresponding disc from the pile and look at the file, or calculate its CRC). Now I no longer archive files on CD/DVDs (neither reliable nor practical) but it’s still useful to keep tracks of things.

Reply

Thanks a ton man………….it works like anything…..great work

Reply
Spyros Hytiris6 years ago

Thank you so much!

Reply

The best one is missing :

mythicsoft.com/agentransack/Page.aspx?page=download

Reply
carlo8 years ago

finally… free from DOS’ dir command, excellent tools!

Reply

Brilliant!!.. Just what Ive been looking for, Thanks!

Reply
Dhruva11 years ago
Contents

Mac App Subdirectories Contents Creator

Thaks a ton man………….it works like anything…..great work……………

Reply

nice tools this is great! thanks Raymond.

Reply

Leave a Reply