diff options
Diffstat (limited to 'bin/mycsv2ledger')
-rwxr-xr-x | bin/mycsv2ledger | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/mycsv2ledger b/bin/mycsv2ledger index d01ced6..f59e3e3 100755 --- a/bin/mycsv2ledger +++ b/bin/mycsv2ledger @@ -3,13 +3,14 @@ set -e infile="$1" +dirname=$(dirname "$infile") basename=$(basename "$infile" .csv) -outfile="${2:-$basename.ledger}" -rulesfile="$basename.rules" +outfile="${2:-$dirname/$basename.ledger}" +rulesfile="$dirname/$basename.rules" { - find * -name "$infile.rules" -execdir cat '{}' +; - find * -name "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +; + find * -wholename "$infile.rules" -execdir cat '{}' +; + find * -wholename "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +; } > "$rulesfile" hledger print --rules-file "$rulesfile" -f "$infile" > "$outfile" rm "$rulesfile" |