Skip to content

command move

zmworm edited this page Mar 31, 2026 · 23 revisions

move

Move an element to a new position or parent.

Synopsis

officecli move <file> <path> [--to <parent>] [--index N]

Description

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.

Arguments

Name Type Required Default Description
file FileInfo Yes - Office document path
path string Yes - DOM path of the element to move

Options

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.

Examples

# 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

Notes

  • For Word documents, the move index is 0-based to match CLI convention.
  • The --index parameter is 0-based (array convention), unlike path indices which are 1-based.
  • Moving an element preserves all its properties and children.

See Also


Based on OfficeCLI v1.0.28

Clone this wiki locally