folder

A Scala function to list subdirectories in a directory

If you ever need to generate a list of subdirectories in a directory in Scala, here's one way to do it:

def getListOfSubDirectories(directoryName: String): Array[String] = {
  return (new File(directoryName)).listFiles.filter(_.isDirectory).map(_.getName)
}

I intentionally wrote that function in a short, "Scala like" style, but you can expand it to multiple lines, if you prefer.

To demonstrate the use of this directory-listing function, you can print all your subdirectories like this:

Mac Finder font size (folder font size)

Mac Finder font size FAQ: How do I adjust the Mac Finder font size (also known as the Mac Finder folder font size)?

You can adjust the Mac Finder font size by right-clicking on an open area of a Mac Finder folder, then selecting the Show View Options menu item. From the dialog that is displayed you can adjust the Finder folder grid size, font size, and a couple of other things there, including:

Mac Desktop font size (and icon size)

Mac Desktop font size FAQ: How do I adjust the Mac Desktop font size? (Related: How do I adjust the Mac Desktop icon size?)

You can adjust the Mac Desktop font size (and Mac Desktop icon size) by right-clicking on an open area of your Mac Desktop, then selecting Show View Options.

From that dialog you can adjust the Desktop icon size, Desktop font size, and a couple of other things there:

Mac Finder 'new folder' keystroke bug

While replying to a comment on an earlier Mac Finder new folder keystroke article, I found a bug in the Mac OS X Finder that I thought I'd mention here as well to make it easier for people to find. In short, the keystroke you can normally use to create a new Finder folder is:

[Shift] [Command] n

Mac Dock folder tip - How to move a folder to the Mac Dock

Mac Dock FAQ: How do I move a commonly used Mac folder to the Dock so I can access it easier?

When you first buy a Mac, the right side of the Dock (the right side of the highway stripe on the Mac Dock) will have just the basic items on it, such as the Applications and Downloads folders. What a lot of people don't know is that you can put links (shortcuts) to your own folders there as well. In fact, this is a great place to put shortcuts to your most commonly used Mac folders.

The Mac Finder new folder keystroke command

Mac OS X Finder FAQ: How do I create a new Mac Finder folder using the keyboard? (Or, What is the Mac Finder new folder keystroke or keyboard command?)

Mac Finder keyboard tips - keystroke to create a new Finder folder

To create a new folder in the Mac Finder using the keyboard, make sure you're in the folder (directory) where you want to create a new folder, and then press the [Command][Shift][n] keystoke.

Mac OS X Finder - delete files using keyboard keys

Mac OS X Finder delete FAQ: How can I delete a file or directory in the Mac Finder using the keyboard (keystroke)?

By now you've probably figured out that you can't just delete a file in the Mac Finder using the delete key. The solution?

Mac folder size - how big is this folder?

Mac OS X Folder FAQ: How do I determine the size of a Mac folder?

Answer: I started to write about how you could use the Unix "du" (disk usage) command on a Mac OS X system to determine the Mac folder size, but then I realized there's a little more obvious approach: Use the "info" command when you have a folder selected in the Mac Finder.

Mac folder size

Using your Mac "Desktop" folder as an example, here's how it works:

How to show the full path to the current Finder folder

So, you're sitting there, looking at your Mac Finder window, and you see the file you need to work with, but wait ... what is the path to the directory you're looking at?

The Finder is a clever interface -- especially now that it sports four different views -- but at times like this, it just leaves you hanging. I run into this problem all the time when I go to upload a file using any of my web-based email clients, or when I upload a file using a web form.

Perl directory list - How do to list all .html files in a directory

Perl directory list FAQ: How do I generate a list of all .html files in a directory?

Answer: This question is similar to another Perl FAQ, How do I do (fill in the blank) for each file in a directory?

The answer is, in fact, very similar. The only thing you need to do differently is to put a search pattern around the readdir statement.

Syndicate content