Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Flatten a directory structure UNIX
There may be times when you want to consolidate all the files in a directory and its sub-directories (or a folder and its sub-folders) into a single directory or folder. For example, you may have a folder with sub-folders for years, and other sub-folders in each year folder for months, and you may want to move files in the month folders all to the top level.

Doing this manually is a complex and time-consuming process. While you might be able to do this by using a search - for example, if all the files are, say, Excel files, you can search for Excel files in the top folder, then just copy them all to a new folder - if there are lots of different types of files, this wouldn't make things easier.

Fortunately, there's a way to do this from a command line. On the BedroomLAN blog, Alexios presents two commands that will do this:

find -type f -print0 | xargs -0 -I%%% cp %%% $FLAT_DIRECTORY

Replace $ROOT_DIRECTORY with the top level directory containing all the sub-directories and files, and replace $FLAT_DIRECTORY with the directory you wish to contain all the files. Note that this command will overwrite any files with the same name, so if you don't have uniquely named files, it's not ideal.

You can also use the ln command instead of the cp command, and this will not overwrite files, but will give error messages if there are duplicate file names. See the blog post for more details on this. H/t to robg for pointing this out.
  Post a comment  •  Comments (12)  
  • Currently 1.57 / 5
  You rated: 1 / 5 (7 votes cast)
[13,476 views]  View Printable Version
Turn off automatic attachment preview in Mail Apps
Mail, by default, provides a preview of attachments in can read, such as graphics and PDF files. However, you can run a command in Terminal to turn this off. Run the following:
defaults write DisableInlineAttachmentViewing -bool yes
Quit Mail and relaunch it. When you view a message, all attachments will be shown as icons only. To restore the original functionality, run this command:
defaults write DisableInlineAttachmentViewing -bool no
Found on StackExchange.
  Post a comment  •  Comments (0)  
  • Currently 3.55 / 5
  You rated: 5 / 5 (11 votes cast)
[22,142 views]  View Printable Version
How to Email Pictures from iPhoto Using Instead of iPhoto's Built-in Email Feature Apps
iPhoto 11 added an awful new built-in email service that replaces the previous functionality: when sending an email, it used to open Mail and attach the photos to a new email. Now, it uses a poorly designed, built-in email functionality that ruins everything. To send photos again using Mail, run the following command in Terminal:

defaults write EmailApp Mail

To return this functionality to iPhoto, run the following command in Terminal:

defaults write EmailApp iPhoto

(Originally found here.)
  Post a comment  •  Comments (5)  
  • Currently 2.00 / 5
  You rated: 2 / 5 (13 votes cast)
[11,493 views]  View Printable Version
Print large Numbers tables on one page Apps
I find frustrating the way Numbers prints large tables – they're often split both horizontally and vertically across multiple pages.

One way to print a large table on a single page is to copy the table and open it in Preview. In Numbers, click the dragging square at the top left of the table. (You need to scroll to the top of the table to see it.) Press Command-C, open Preview and press Command-N. Print away.

[kirkmc adds: Interesting: if you paste a table into Preview, it's displayed with no borders or extra space, as if it were a PDF. (There's a hint explaining this.) However, when you print, make sure to select Scale to Fit, then Fill Entire Paper. I tried pasting a long table - about 300 lines - and Preview, using the default print settings, would have printed the entire table on one page.]
  Post a comment  •  Comments (5)  
  • Currently 2.43 / 5
  You rated: 2 / 5 (7 votes cast)
[6,759 views]  View Printable Version
Extract names and emails from a text file UNIX
I have a recurring need to extract full names and email addresses from a plaintext archive of email messages. The archive is created by selecting a bunch of emails in Mail, copying them, pasting into TextEdit, and converting to plain text.

For each message in the file, the first line contains the information I wanted:
From: Joe Example <>
I wanted one email address per line, suitable for pasting into another location. I am far from an expert with the bash shell, but here's what I came up with—I imagine there are many more efficient ways to do this, as I'm sure experienced perl, sed, awk, etc. users may point out. Note that this is highly dependent on the format created by Apple's Mail app in OS X 10.8.

grep 'From:' /path/to/archive.txt | cut -f2 -d\< | cut -f1 -d\> | pbcopy

The grep bit pulls out the entire From: line, then the first cut command grabs the email address and the trailing close-bracket, by setting the delimiter to an open bracket. The second cut eliminates the closing bracket, by setting that as the delimiter. The output will be one email address per line, sitting on your clipboard ready for pasting. (To debug, just remove the | pbcopy bit to see the output.)

I also wanted to extract the names, and came up with a variant to do just that:

grep 'From:' ~/Desktop/testfile.txt | sed -e 's/: /:^/g' | sed -e 's/ \</^\</g' | cut -f2 -d^ | pbcopy

This one is messier, as names can contain one or more spaces. After getting the From: line, sed is used (twice) to add a carat delimiter immediately after From:, and immediately before the opening bracket of the email address. I then used cut, with the delimiter changed to the carat, to extract the full name (field two) from the found lines. Again, the results are copied to the clipboard; leave this bit off for debugging.

With the names and addresses extracted, it's fairly easy to do other stuff with them. In my case, I'm reading them into a couple of array variables in a bash script, so I can then output a name and email address pair to consecutive locations on my multi-pasteboard. If you want to use the names in an array in a bash script, you'll want to change the array delimiter from a space to a newline:


Without this, your array will get split anywhere there's a space in the name values ... or so I've heard, not that it's ever happened to me!
  Post a comment  •  Comments (12)  
  • Currently 3.20 / 5
  You rated: 1 / 5 (10 votes cast)
[7,462 views]  View Printable Version
Set iPhone to flash LED for alerts iOS devices
A recent post on The Mac Observer pointed out a useful way to set alerts on an iPhone. If you dig deep into the ACcessibility settings (Settings > General > Accessibility), in the Hearing section, you'll find an option called LED Flash for Alerts. If you turn this on, you'll get a flash whenever you get an alert, such as for phone calls, text messages, etc. This is most useful if you're in a situation where you need to turn the sound off on your iPhone, or if you're in a noisy environment, and may not hear any alert sounds.

[kirkmc adds: This only works if the iPhone is asleep; in other words, if the screen has gone dark. It would be helpful if it flashed in all cases. Also, if you have the iPhone on a table with the LED on the bottom, you may not see the flash.]
  Post a comment  •  Comments (5)  
  • Currently 3.63 / 5
  You rated: 1 / 5 (19 votes cast)
[6,765 views]  View Printable Version
Change screensaver slide duration System 10.8
I like to use images of various quotes as my screensaver, but the default 3-second duration for each slide isn't enough for several of the quotes. After discovering that Apple, amazingly, no longer provides a built-in way to alter the duration of each slide, I set out to figure out how to change it to suit my preference. It works, but it's a bit of a pain, so if anyone knows of an easier method, please contribute.

I found the method on this page from CNET, the author of which apparently found it here. In 10.8, no matter how I tried altering the permissions of the relevant file and folder in the Finder or "unlocking" the file (as XCode refers to it), I could not get XCode (or TextWrangler) to write to the file, so I had to alter the CNET instructions a bit. (Side rant: I feel justified in refusing to resort to the terminal for a simple permissions change, a capability that has supposedly existed in the Finder for 9 major iterations of OS X.) Do the following:

  1. Navigate to this folder in the Finder and find the file called "EffectDescriptions.plist":
  2. Option-drag the file to create a duplicate copy and rename it "EffectDescriptions.original.plist" (just in case). Authenticate when asked.
  3. Drag "EffectDescriptions.plist" to the desktop (it will copy).
  4. Open the desktop copy in XCode, TextWrangler, or your preferred text editor.
  5. Hit Command-F to search for the entry called "JustASlide" (this works in XCode and TextWrangler).
  6. Find the sub-entry called "mainDuration." Change its numerical value from 3 to whatever value you prefer (in seconds).
  7. Save the file, close it, and drag it back into the folder you copied it from. It will ask you to authenticate, and then whether to replace the file. Do both. (You did do step 2, right?)
  8. In Terminal, type:
    sudo chown root /System/Library/PrivateFrameworks/Slideshows.framework/Versions/A/Resources/Content/EffectDescriptions.plist
    This will set the permissions of the file as they were before.
  9. Go to System Preferences and confirm with a slideshow preview that your change was effective.

As I said earlier, this is an ugly way to accomplish what should be a very simple preference setting, so if anyone knows of a more elegant solution, please share. I toyed with the idea of having a separate screensaver file in my own Library folder, but I wasn't able to determine whether that would work. Given that we're altering this setting in a private framework, it seems to me that it wouldn't.

  Post a comment  •  Comments (4)  
  • Currently 2.40 / 5
  You rated: 1 / 5 (10 votes cast)
[8,714 views]  View Printable Version
Added features when using Stocks app in landscape mode iOS devices
In iOS 3.0, Apple introduced landscape view for the Stocks app. At that time, it still only allowed date ranges of 1d, 1w, 1m, 3m, 6m, 1y, and 2y.
read more (94 words)   Post a comment  •  Comments (3)  
  • Currently 3.07 / 5
  You rated: 1 / 5 (14 votes cast)
[3,692 views]  View Printable Version
Install Windows 7 on external drive using Boot Camp (Lion) Install
Having purchased a Segate GoFlex Desktop Thunderbolt Adapter made me wonder if it's possible to install a Bootcamp-Partition on an external Drive. Well it works; sort of.
  1. Launch Boot Camp Assistant.
  2. Select the local Drive for installation (not the external Drive) it will take about 20 GB of disk space.
  3. Boot Camp Assistant will now repartition your local drive.
  4. Wait a while for Boot Camp Assistant to finish preparing the drive.
  5. When the Windows 7 Installer comes up simply choose the external drive as target, not the local one.
  6. Proceed with the installation.
When booting your Mac (holding the Option key) you'll now see that there is a local Windows 7 boot volume. Unfortunately, you will have wasted 20 GB creating a partition on your main drive.

[kirkmc adds: I haven't tested this. I don't know if Disk Utility can delete that partition; live partitioning is possible, but in some cases certain partitions can't be deleted.]
  Post a comment  •  Comments (10)  
  • Currently 2.64 / 5
  You rated: 1 / 5 (11 votes cast)
[51,286 views]  View Printable Version
Remove Genius mixes from iTunes Apps
I spotted something today in iTunes 11, which I don't recall seeing before. If you right-click on a Genius Mix icon, you can choose Remove > Genius Mix name> and delete it from the Genius Mixes list. If you want to get all your Genius Mixes back, you can right-click anywhere in the white space of that window and choose Restore All Mixes to get them all back. But you still have no control over how Genius Mixes are created.
  Post a comment  •  Comments (0)  
  • Currently 2.89 / 5
  You rated: 1 / 5 (9 votes cast)
[5,224 views]  View Printable Version