Command xmove
Name
xmove Moves/renames an xml file to a filename based on an expressionSynopsis
xmove [-x expr] [-d dir] [e extension] [-ns namespace [-ns namespace ...]] [-f] filesOptions
-x,-xpath xpath-expr | Evaluate the xpath expression on each file to generate the basename of the new file |
-d,-dir dir | Specifies a new directory to move the file to |
-ns namespace | Adds namespace declarations. Required if the xpath expression requires namespaces |
-f | Force move (deletes target file if it exists) |
-mkdir | Create parent directories of target if not exists |
files | List of files to move/rename |
Description
Moves/renames an xml file to a filename based on an expression.For each file given, the xpath-expr is evaluated with the context of the specified file. The result is cast to a string (equivilent to passing the result to the fn:string() function. This because the new basename of the file.
The full target filename is composed of
[dir][basename][extension]
If no [dir] is provided (-d) then the current directory is usedif no [extension] is provided then the extension of the current file is used.
The xpath expression can be used to create part of the destination directory.
For example
Move all xml files to a directory equal to the root element name and base name equal to the text value of the child id element.
If the XML looks like
<root>
<id>123</id>
<name>value</name>
</root>
<id>123</id>
<name>value</name>
</root>
xmove -mkdir -x 'concat(node-name(/node()),"/",/node()/id)' *.xml
Will move the file to root/123.xml
Commands
CategoryCommands