Moves or renames one or more remote files.


mv <file> [ <file2> ... ] [ <directory>/ ][ <newname> ]


Destination directory or newname or both must be specified. Destination directory must end with slash. Operation mask can be used instead of new name. Filename can be replaced with wildcard to select multiple files.

Alias: rename

Effective options: failonnomatch

XML log element: mv



mv index.html public_html/
mv index.html about.*
mv index.html public_html/about.*
mv public_html/index.html public_html/about.html /home/martin/*.bak
mv *.html /home/backup/*.bak

Converting to .NET Assembly

When converting script to .NET Assembly, map mv command to Session.MoveFile method.

Parameters mapping: Command parameter file maps to method parameter sourcePath. When multiple source file parameters are used, you need to call Session.MoveFile multiple times. Command parameter directory/newname maps to method parameter targetPath. You have to convert relative paths to absolute paths.

For example, following script snippet:

cd /home/martinp
mv public_html/index.html public_html/about.html *.bak

maps to following PowerShell code:

$session.MoveFile("/home/martinp/public_html/index.html", "/home/martinp/*.bak")
$session.MoveFile("/home/martinp/public_html/about.html", "/home/martinp/*.bak")
  scriptcommand_mv.txt · Last modified: by martin

Search Documentation

This page


About donations

$9   $19   $49   $99

About donations



Site design by Black Gate