Date conversion in .QIF file

I need to convert my .QIF files for Quicken from french format to US format:

All the strings "Dday/month/year" need to be converted to "Dmonth/day/year"

Example below:
!type:Bank
D20/09/05
T-60.00
NCarte
PRETRAIT 18/09 12H
MRET. DAB 45614

New to apple script, thank you for any help provided.

Posted on Sep 21, 2005 3:45 PM

Reply
3 replies

Sep 21, 2005 4:26 PM in response to Philippe Roux

Maybe it's better to download and install the Satimage osax, and use regular expressions in AppleScript. Once the Satimage osax installed:
- launch Script editor
- run:
-- untested
set theFile to alias [the path to your file here, like "Macintosh HD:Users:login:Desktop:myfile"]
set theText to read theFile
set theText to change "^D([0-9]{2})/([0-9]{2})/([0-9]{2})$" into "D\\2/\\1/\\3" in theText with regexp
set eof theFile to 0
write theText to theFile

Sep 21, 2005 4:44 PM in response to Philippe Roux

There are many ways of doing this without using AppleScript. Several shell utilities make trivial work of this kind of thing.

This one-line awk script will show you one way:

awk -F / '/^D/ {print "D"$2"/"substr($1,2,2)"/"$3;}; /^[^D]/ {print $0;}' input.qif > output.qif



To explain this:

awk -F /


This invokes the awk command, using the -F switch to define the field delimiter. By specifying the forward slash we can break the date into its components.

/^D/ {print "D"$2"/"substr($1,2,2)"/"$3;};


This says that for all lines that begin with D (/^D/) print out a D followed by the second field (as denoted by the / field delimiter), then a / followed by 'substr ($1,2,2)' which takes the first field (e.g. 'D20') and strips off the first character), then another /, then the third field. This is the line that reformats the data.

Then:

/^[^D]/ {print $0;}


Takes every line that doesn't begin with a D and prints the entire line.

The two filenames, 'input.qif' and 'output.qif' denote the source file and the new file that will be created with the reformatted data. Adjust these file names as appropriate.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Date conversion in .QIF file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.