Archive for the ‘MacOSX’ Category

How to export videos from iPhoto and keep their date

January 13th, 2014 No comments

When importing files from family iPhones on MacBook Air, Google Picasa does not process rotation properly. I have to use iPhoto. However iPhoto does not export properly date of videos. In order to keep my archive on disk properly organized, I wrote myself two scripts.

I export images and videos from iPhoto using:

Field Value
Kind Original
File name Use filename
Subfolder Format Event Name

This will place them into subfolder on the disk. Now in each directory I run script iphoto-touch-mov-by-prev-image, which will touch the videos to have the same date/time as the closest image.

Afterwards I run all files through a script iphoto-copy-export-to-archive-dir which will put them into YEAR/YEAR-MONTH-DAY subfolder in my archive.

In order to process multiple subdirectories I use:

for DIR in `find . -type d`; do
    iphoto-touch-mov-by-prev-image $DIR
    iphoto-copy-export-to-archive-dir /Volumes/Archive $DIR/*.*
Categories: MacOSX, Missing Answers Tags:

Import CSV with UTF-8 into Excel for Mac

June 28th, 2013 3 comments

Excel for Mac 2011  does not support UTF-8 in CSV files. On Windows you can simply add Byte Order Mark (BOM) to the file and it will open correctly in Excel. This does not work on Mac. You can try importing the file with different encoding and some people declare success with UTF-16 Little Endian, but for me this simply does not work.

The best solution that I have found is a script made by Konrad Foerstner, which I have improved little bit, to support different colum delimiters.

Download the script from Github, install library for writing Excel format sudo easy_install openpyxl.

Now you can covert the file from CSV to XLSX.

Categories: MacOSX, Missing Answers Tags:

Mac OS X: Cannot edit crontab

February 26th, 2013 4 comments

I wanted to edit crontab for a user on Mountain Lion and it did not work. Repairing permissions with Disk Utility did not help. I saw following error messages:

$ crontab -e
crontab: no crontab for player - using an empty one
crontab: "/usr/bin/vi" exited with status 1

$ EDITOR=vim crontab -e
crontab: no crontab for player - using an empty one
crontab: temp file must be edited in place

$ EDITOR=mcedit crontab -e
crontab: no crontab for player - using an empty one
crontab: installing new crontab
crontab: tmp/tmp.13840: No such file or directory
crontab: edits left in /tmp/crontab.Gyxvel8v43

$ crontab path-to-file-to-replace-current-tab
crontab: tmp/tmp.13784: No such file or directory

To reduce the problem, I have used mcedit. I have found that someone had this issue in 2007 – UNSOLVED. If you were a programmer you would be suspicious about the path without the leading slash. But how to find the real path? I made me comfortable with dtruss (strace for Mac) but it did not move me forward, I just saw that it is problem when opening the file for writing. But hey, this is BSD! We should find sources … and indeed they are available. Now it took just a while to go through the C code and finally find file

The solution of this problem is to create missing tmp directory in /var/at!

mkdir /var/at/tmp
chmod 700 /var/at/tmp

I have no idea where I have lost the tmp directory. But I should not be supposed to drill into the source code. Am I?

UPDATED: I believe this problem was caused by my attempt to wipe Parallels out of the system. I was deleting all files installed by the package and afterwards I was deleting empty directories system wide.

Categories: MacOSX, Missing Answers Tags: