15

How can I delete multiple transactions in a batch in GnuCash?

My specific use-case is that I am treating each year as a standalone gnucash file. I start with a copy of the previous year and import the current year transactions into it in order to benefit from trained Bayesian automatic transaction mapping during import. After importing the current year data, I then wish to delete the previous year's data.

3
  • I want to change from multi-year GnuCash files to single year too. Can you please clarify how you import current year transactions and from where. I can only guess that you are doing this early in each new year.? Commented Aug 10, 2022 at 11:09
  • 1
    @MartinZaske I have a gnucash file for each year. So when I want to start a new year, say 2022, I make a copy of last years file (2021), rename it to 2022-whatever and open it. Then I import my 2022 transactions to this file (this can be done anytime, for me it's usually after the year is over). The transactions come from QFX quicken files I export from my bank and credit card websites. When I'm done importing I'll delete all the 2021 transactions. You'll have to set "opening balances" for some accounts with this method
    – User
    Commented Aug 10, 2022 at 20:15
  • Thank you. I did not know about external data from banks. Some GnuCash users operate also multi-year-eternal-files. And I wondered whether you export and import maybe from such a file. Smart to keep the old data to use the automagic in GnuCash and only delete later. Commented Aug 12, 2022 at 12:08

4 Answers 4

12

As a workaround I made a shortcut key for deleting transactions. With GnuCash closed, I modified the accelerator-map file.

In GnuCash 2.6 and older: C:\Users\username\.gnu-cash\accelerator-map

In GnuCash 3.0 and newer: C:\Users\username\AppData\Roaming\GnuCash\accelerator-map

Ubuntu (as mentioned in comments): /home/username/.local/share/gnucash/accelerator-map

I changed the following line (you might need to add the line entirely)

; (gtk_accel_path "<Actions>/GncPluginPageRegisterActions/DeleteTransactionAction" "")

To:

(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/DeleteTransactionAction"
"<Primary>Delete")

I removed the semi-colon ; (which acts as a comment character) at the beginning of the line and I added the text <Primary>Delete

The first time you use the key combination GnuCash will show a pop-up dialog box asking if you want to save the transaction and has check boxes to automatically do this in the future. Pick one of the check boxes. You can undo this choice in the future by going to the menu Actions->Reset Warnings... (a dialog box appears asking which warnings to reset)

Now I could delete transactions by pressing ctrl+delete (Note: this is the delete key, not the backspace key. But you can pick whichever key combination you want). Pressing and holding this key combination allowed continuous deleting at a predictable rate so it was quite easy to delete a few hundred transactions quickly.

(EDIT: Note in recent version, GnuCash 4.9, although rate of deletion might still be predictable it no longer seems to update the UI as you delete transactions when holding down the key combo, which makes it harder to eyeball the deletion rate. I am now more comfortable repeatedly pressing the key combo rather than holding down)

Might not be the best solution if you have many thousands of transactions that you want to delete but for a few hundred it was quite painless.

2
  • 1
    Works great. However, in Ubuntu 19.04, my accelerator-map file was located in /home/username/.local/share/gnucash/accelerator-map Commented Jun 1, 2019 at 16:35
  • I like this idea, came here for a multiple-select-delete GnuCash feature. The OP shared that he imports current year data after opening a copy of the previous year. Any practical hints how my machine-gun shortcut-deleting will not hurt current year transactions? Maybe some display-filter where GnuCash will kindly not delete what is (temporarily) not displayed? Thank you. Commented Aug 10, 2022 at 11:12
7

As a follow-up to this very useful info, on a Windows PC, the file is located in:

C:\Users\UserName\AppData\Roaming\GnuCash\accelerator-map

The way the edited line is displayed in the above answer is correct but it may not be immediately obvious to everyone that like some other languages, the semicolon needs to be removed as well. The semicolon is a comment tag that disables the line it is on.

Notes:

<Primary> is the same as "Command" on macs and "Ctrl" on Windows. Other modifiers are <Shift> and <Alt> and they can be combined so to make it a bit more difficult to do accidentally, my new line is:

(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/DeleteTransactionAction" "<Primary><Shift>Delete")

AKA: Control + Shift + Delete

I presume it was the same in earlier versions but I am new to GNUcash so it's also useful to note that, at least as of GNUcash 3.5, this keyboard shortcut triggers the Yes/No dialog to confirm that the transaction should be deleted. Additionally, you can select to ignore the dialog for the rest of the session or never show the dialog.

1
  • 1
    Thanks for explaining what <Primary> does!
    – jsherk
    Commented Jan 15, 2021 at 0:03
2

And here are my notes for a Windows (10) setting, when using the portable version of GnuCash from here:

GnuCash Portable website for download and docu

The file "accelerator-map" for the keyboard-shortcut-hack is now located here:

[path-to-your-portable-installation]\Data\GNCDataHome\accelerator-map"

I tested this on Win 10 pro 64bit and with GnuCash Version 4.13 portable just now and it works great. I used this syntax:

(gtk_accel_path "<Actions>/GncPluginPageRegisterActions/DeleteTransactionAction" "<Primary>Delete"); Martin

You can see that I took the information that ";" is for comments and I marked this line with my name, as the one I have edited for later reference. The file has got 292 lines, so could be useful next time I want to have a look.

TL/DR

I have noticed that GnuCash is getting messy, when I have to work on several "clients" in parallel: The settings (for example the active-period) are not properly kept separate for each project. I do accounting for several different NGOs and some cash-boxes.

This is why I am using the portable version. Even when working for the same client and starting a new calendar-year (as is the context of this question), I start a new install in a separate folder, and it is also a good moment to look for a version-update for GnuCash portable.

-2

I haven't tried yet but in theory you should be able to delete transactions with SQL using the SQLite file format. Of course you need to have a basic understanding of the data structures but then I imagine it to be quite powerful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .