Too bad I don't have my Mac working right now or I would have prepared an AppleScript application for you...
Anyway, you can copy-paste this to a new export_to_checkbook file :
Code: Select all
function exportToCheckBookFormat() {
REVERSE_COMMAND=$(type tac 1>/dev/null 2>&1 && echo "tac" || echo "tail -r")
head -n1 "$1"
tail -n+2 "$1" | $REVERSE_COMMAND
}
function exportToCheckBookFile() {
DESTINATION_NAME=$(echo "$1" | sed -E 's|^(.*)\.([^.]*)$|\1_checkbook.\2|g')
exportToCheckBookFormat "$1" > "$DESTINATION_NAME"
}
while (( "$#" )); do
[ -f "$1" ] && exportToCheckBookFile "$1"
shift
done
and then type in the terminal :
That script reverses all but the first line of the files given as an argument, appending '_checkbook' to the file names. Since 'tail -r' is only valid on BSD systems* (like MacOS X) I had to test it using tac. I suspect that tac is available with MacOS X too, which would fix your problem, so I kept the command selection in the script.
So all you have to do from the terminal now is :
And it would output a new 'account_checkbook.csv' file.
Making this script accept it's input from the input stream is simple... but I don't remember how right now

! I'll add this feature tomorrow if you like : I just need to read back some of my old scripts at work to refresh my memories !
Now, if you mix the "Drag 'n' Drop Applet Shell"
from here with the answers
from here and the script above, you should have a user friendly drag and drop tool to do all your conversions from the Finder.
Since I've never touched AppleScript (well... not for 20 years at least), I can't do it reliably without an actual Mac at hand, maybe someone else could help ?
(I'm quite bad at shell script writing... if anyone here would be glad enough to help me simplify this, fix bad habits and vulnerabilities (I know I did not check for file name conformance to expected *.* format), etc... I would be grateful !)
* According to GNU bash, using tail -r on BSD is not a good idea either :
GNU 'tail' can output any amount of data (some other versions of
'tail' cannot). It also has no '-r' option (print in reverse), since
reversing a file is really a different job from printing the end of a
file; BSD 'tail' (which is the one with '-r') can only reverse files
that are at most as large as its buffer, which is typically 32 KiB. A
more reliable and versatile way to reverse files is the GNU 'tac'
command.