# Write All Keywords to Text File

**URL:** https://community.bildhuus.com/t/write-all-keywords-to-text-file/593
**Category:** Extensions and Snippets
**Tags:** snippet
**Created:** [13 June 2025 10:25 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593 "2025-06-13T10:25:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Soenke](https://community.bildhuus.com/user_avatar/community.bildhuus.com/soenke/32/59_2.png) [@Soenke](https://community.bildhuus.com/u/Soenke)
#### Post date: [13 June 2025 10:25 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593/1 "2025-06-13T10:25:03Z")

</div>

This is a snippet that exports a list of all keywords encountered in the currently loaded library to a text file. Hierarchical keywords will be written as an indented tree with tab characters used for indentation.

2025/09/27: Updated to output in Lightroom Classic compatible format and to sort case insensitively

```JS
// Write All Keywords to Text File

var lines = []
function collect_keywords(kwds, prefix) {
	var kwds_sorted = []
	kwds.forEach(function(kw) {
		if (kw.kind() == "normal")
			kwds_sorted.push(kw)
	})
	kwds_sorted.sort(function(a, b) {
		ak = a.keyword().toLowerCase()
		bk = b.keyword().toLowerCase()
		return ak.localeCompare(bk)
	})
	
	for (i in kwds_sorted) {
		lines.push(prefix + kwds_sorted[i].keyword())
		collect_keywords(kwds_sorted[i].children(), prefix + "\t")
	}
}
collect_keywords(library.rootNode().keywords(), "")
var text = ""
for (i in lines) text += lines[i] + "\n"

var path = chooseFile({
	save: true,
	formats: [{
		name: "Text Files",
		patterns: ["*.txt"]
	}]})
if (path != "")
	writeFileUTF8(path, text)

```

## Installation

1. Copy the snippet source code above to the clipboard
2. In Aspect, go to the “Snippets” page of the settings dialog and click “Add Snippet…”
3. Paste the source code into the “Source Code” area - the “Menu Entry” field will be filled out automatically

The new menu entry should now be visible in the “File” menu and you can also optionally assign a keyboard shortcut in the “Shortcuts” section of the settings dialog.

---

<div class="post-metadata">

### Author: ![jose](https://community.bildhuus.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@jose](https://community.bildhuus.com/u/jose)
#### Post date: [23 December 2025 21:42 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593/3 "2025-12-23T21:42:14Z")

</div>

Very interesting snippet. In my workflow, I use the Keywords list a lot to find and correct small writing errors at a glance. When Aspect is up and running, I’ll try it out. I’m trying to get it to work on Linux (Fedora or Debian) with my photos stored on a Qnap NAS, but something always goes wrong.

---

<div class="post-metadata">

### Author: ![Soenke](https://community.bildhuus.com/user_avatar/community.bildhuus.com/soenke/32/59_2.png) [@Soenke](https://community.bildhuus.com/u/Soenke)
#### Post date: [24 December 2025 08:11 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593/4 "2025-12-24T08:11:05Z")

</div>

> I’m trying to get it to work on Linux (Fedora or Debian) with my photos stored on a Qnap NAS, but something always goes wrong.

Because I ran into issues there, how do you have the NAS folder mounted locally? At least the GVFS user mounts unfortunately do not support modifying large files, so they are fundamentally incompatible with the metadata/thumbnail cache. I switched to using the server version of Aspect instead of trying to get it to work this way, but that’s probably not an option in your case.

---

<div class="post-metadata">

### Author: ![jose](https://community.bildhuus.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@jose](https://community.bildhuus.com/u/jose)
#### Post date: [24 December 2025 09:47 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593/5 "2025-12-24T09:47:21Z")

</div>

Of course it’s an option! I’ll try Aspect Server these days. Thanks and saludos,

---

<div class="post-metadata">

### Author: ![Soenke](https://community.bildhuus.com/user_avatar/community.bildhuus.com/soenke/32/59_2.png) [@Soenke](https://community.bildhuus.com/u/Soenke)
#### Post date: [24 December 2025 10:16 UTC](https://community.bildhuus.com/t/write-all-keywords-to-text-file/593/6 "2025-12-24T10:16:38Z")

</div>

I just meant because it probably can’t run on the QNAP directly – once we have a Linux/aarch64 version, that might change, though.
