-
Notifications
You must be signed in to change notification settings - Fork 107
command move
zmworm edited this page Mar 31, 2026
·
23 revisions
Move an element to a new position or parent.
officecli move <file> <path> [--to <parent>] [--index N]
Moves the element at the specified path to a new location. You can reorder within the current parent (using --index alone) or move to a different parent (using --to). Returns the new path of the moved element.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
file |
FileInfo | Yes | - | Office document path |
path |
string | Yes | - | DOM path of the element to move |
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
--to |
string | No | current parent | Target parent path. If omitted, reorders within the current parent. |
--index |
int | No | append to end | Insert position (0-based). If omitted, appends to end. |
# Move paragraph 5 to the beginning of the document
officecli move report.docx /body/p[5] --index 0
# Move paragraph 3 to position 1 (second position)
officecli move report.docx /body/p[3] --index 1
# Move a paragraph to the end (default when no --index)
officecli move report.docx /body/p[2]
# Move a shape from slide 1 to slide 2
officecli move slides.pptx /slide[1]/shape[3] --to /slide[2]
# Move a shape to a specific position on the target slide
officecli move slides.pptx /slide[1]/shape[3] --to /slide[2] --index 0
# Reorder slides
officecli move slides.pptx /slide[3] --index 0
# Move a table row
officecli move report.docx /body/tbl[1]/tr[3] --index 0- For Word documents, the move index is 0-based to match CLI convention.
- The
--indexparameter is 0-based (array convention), unlike path indices which are 1-based. - Moving an element preserves all its properties and children.
Based on OfficeCLI v1.0.28