[GNC] Fwd: Relative paths in transaction associations

Justin Haynes justin at justinhaynes.com
Tue Mar 5 15:59:35 EST 2019


This all worked very well and was very simple in a text editor.  The
process was deterministic - there was no text that matched my searches
other than what needed to be replaced.  I'll summarize for posterity:

Problem:  The problem was that I wanted to be able to use GNUCash from
multiple computers with multiple OSes and to have access to the files
associated to the transactions, such as receipts.

Solution:  The solution was twofold.

1. Enable the already-present feature meant for this very purpose in   Edit
-> Preferences -> General -> Path head for Transaction Association Files,
so that all future files I attach to transactions would be to relative
paths, and so that GNUCash would know where to find the files when I right
click on a transaction and click
Open Associated File/Location.
2. Replace all my absolute paths in my xml file with relative ones.  This
was as simple as replacing all occurrences of  "file:///<path head>" with
"file:/" where <path head> was any number of things for the past 3
computers I used over the years.  I did the replacement for as many sets of
absolute paths corresponded to past locations on those computers.  This
left only a relative path.

Since the path head is stored in preferences local to the current
installation, I don't have to do anything special moving from one computer
to the next.  GNUCash knows where to look for files under the path head.

Additionally I use a cloud service to synchronize my files to the correct
location on each computer so that I only have to attach once from whichever
computer I happen to be using.  And likewise from any computer I can refer
to the receipts by simply right clicking on the transaction -> Open
Associated File/Location

As David said, work from a backup.  Meaning:

1. close gnucash.
2. copy the gnucash file to another location entirely.
3. use a utiilty that can extract .zip files, and open this .gnucash file
(only necessary if your gnucash is zipping your files . This is the default
behavior).
4. Edit the resulting file.  Rezip it and rename it so that the zip file is
ending in .gnucash.
5. When satisfied, BACKUP the original file AGAIN, and replace the original
with your edited zipped gnucash file.


Redundant to put this all in the same email, I know, but perhaps a future
user will find all this in one place and be happy.



On Fri, Feb 15, 2019 at 8:24 PM D <sunfish62 at yahoo.com> wrote:

> Justin,
>
> Probably, your best bet is to dig in to the data file directly and change
> the entries there.
>
> NOTE: editing your data file directly can be risky. Always work on a
> backup copy!!!
>
> How you go about this depends on the way you have your data stored (XML,
> database).
>
> XML is straight text, although by default it's compressed (change the
> setting in preferences to store it without compression), so a find and
> replace in a text editor would suffice.
>
> The db backend will require digging around for the table in question, and
> developing an appropriate SQL command.
>
> Oh. Did I mention that you should do this on a backup? You should.
>
> David
>
> On February 16, 2019, at 12:44 AM, Justin Haynes <justin at justinhaynes.com>
> wrote:
>
> OK everything worked as expected, and I can switch between disparate
> machines and still have access to associations!
>
> So I only have one remaining question:Where should I look in the data file
> or in the code or documentation to discover how to programmatically or
> using a text editor change all the absolute paths in my current
> associations to relative ones?
>
> Thanks!,
>
> Justin
>
>
>
> On Feb 13, 2019, at 11:18 AM, Justin Haynes <justin at justinhaynes.com>
> wrote:
>
> OK, so I can see that with a populated "Path head for Transaction
> Association Files", that linking transactions to files after this is
> populated, results in the "Relative" field being checked next to the
> corresponding entry in the "All Transaction Associations" window, and an
> absolute path in the window.  When I have my other laptop, I can experiment
> to see if changing the Path head configured in GNUCash on that laptop will
> result in GNUCash on that machine finding the files associated when I click
> on Open Associated File/Location from the corresponding Transaction.
>
> Second Question: if my experiment works, and GNUCash behaves the way I
> would like, how can I go back and change the links to all previously
> created transaction associations to be relative links to the same files?
>
> Thanks,
>
> Justin
>
> On Wed, Feb 13, 2019 at 10:46 AM Justin Haynes <justin at justinhaynes.com>
> wrote:
>
> > Found it.
> >
> > Edit -> Preferences -> General -> Path head for Transaction Association
> > Files.
> >
> > Now i just need to experiment with it to see how it behaves.
> >
> > On Wed, Feb 13, 2019 at 10:43 AM Justin Haynes <justin at justinhaynes.com>
> > wrote:
> >
> >> What provision is there for relative paths in transaction associations?
> >> I often associate transactions with files where the files are almost
> always
> >> receipts.  This results in a URL to an absolute path which appears in
> the
> >> Tools -> Transaction Associations dialog.  Also from a transaction I can
> >> access the file I linked to with Transaction -> Open Associated
> >> File/Location.  The file opens in whatever program is associated for
> that
> >> file type.
> >>
> >> I would rather have relative paths which resolve with relation to an
> >> absolute base path I can figure.  This would allow me to move from
> system
> >> to system and only change the absolute path on the target system's
> GNUCash
> >> instance.  I then only use one instance at a time on the same files of
> >> course.  These files exist on local machines but sync with a cloud
> service
> >> so that the file is available wherever I'd like it to be.
> >>
> >> Tools -> Transaction Associations brings up the "All Transaction
> >> Associations" window, where I see columns for the Date, Description,
> >> Association (URL link to the resource, either local (file:// with link
> to
> >> absolute path) or remote).  There is then an "Available?" column
> populated
> >> with "Unknown" in each row, and a column called "Relative" with no data.
> >>
> >> Since there is  "Relative" field, I assumed there must be some
> proviision
> >> for this.
> >>
> >> Thanks,
> >>
> >> Justin
> >>
> >>
> >>
> >
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> If you are using Nabble or Gmane, please see
> https://wiki.gnucash.org/wiki/Mailing_Lists for more information.
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>


More information about the gnucash-user mailing list