@@ -11,13 +11,15 @@ useful for batch operations.
1111General usage:
1212
1313```
14- $ ./ docxtools -h
14+ $ .docxtools
1515Usage: docxtools [OPTIONS] <IN_FILE> <COMMAND>
1616
1717Commands:
18- cat List the text from the document to the console
19- grep Search the text in the document like 'grep'
20- help Print this message or the help of the given subcommand(s)
18+ cat List the text from the document to the console
19+ grep Search the text in the document like 'grep'
20+ replace Search and replace in document text and tables
21+ replace-links Search and replace hyperlinks in the document
22+ help Print this message or the help of the given subcommand(s)
2123
2224Arguments:
2325 <IN_FILE> The docx file to operate on
@@ -26,4 +28,46 @@ Options:
2628 -t, --temp-dir <TEMP_DIR> The temporary directory to use. If not specified a system temp directory will be used and cleaned after use
2729 -h, --help Print help
2830 -V, --version Print version
29- ```
31+ ```
32+
33+ ## Example usage:
34+
35+ ### List text contents of a docx file
36+
37+ ```
38+ $ docxtools docs/test.docx cat
39+ docs/test.docx: Normal.dotm
40+ ...
41+ docs/test.docx: Microsoft Office Word
42+ ...
43+ docs/test.docx: 2023-08-25T10:13:00Z
44+ docs/test.docx: A test document written in Microsoft Word.
45+ ```
46+
47+ ### Search a directory of docx files for a specific text
48+
49+ The ` grep ` subcommand supports regex syntax to find text.
50+
51+ ```
52+ $ find docs/folder -name "*.docx" -exec docxtools {} grep '[tT]ext' \;
53+ docs/folder/sample1.docx: text
54+ docs/folder/sample1.docx: Text
55+ docs/folder/sample2.docx: This is a different file that also contains some textual content.
56+ ```
57+
58+ ### Replace all occurrences of a word with another
59+
60+ Change the word 'Test' or 'test' into zzzz and write the modifications to a new file ` test_mod1.docx ` :
61+
62+ ```
63+ $ docxtools docs/test.docx replace '[Tt]est' zzzz docs/test_mod1.docx
64+ ```
65+
66+ ### Replace all occurrences of a hyperlink with another
67+
68+ Replace all occurrences of ` https://main--test--hlxsites.hlx.page ` with ` https://foo.bar.com ` . Any subpaths after the
69+ URLs are kept, so ` https://main--test--hlxsites.hlx.page/contact ` will become ` https://foo.bar.com/contact ` .
70+
71+ ```
72+ $ docxtools docs/links.docx replace-links https://main--test--hlxsites.hlx.page https://foo.bar.com
73+ ```
0 commit comments