Menu  Toggle search  [ ![](https://winscp-
static-746341.c.cdn77.org/assets/images/logos/logo.png?v=7032) WinSCP  Free
SFTP, SCP, S3 and FTP client  for  Windows  ](https://winscp.net/)

  * [ Home ](/eng/index.php)
  * [ News ](/eng/news.php)
  * [ Introduction ](/eng/docs/introduction)
  * [ Download ](/eng/download.php)
  * [ Install ](/eng/docs/guide_install)
  * [ Documentation ](/eng/docs/)
  * [ Forum ](/forum/)

Close

Search

Close

[ Documentation ](/eng/docs/start "Documentation") » [ Features
](/eng/docs/feature_index "Features") » [ Scripting ](/eng/docs/scripting
"Scripting") » [ Script Commands ](/eng/docs/scripting#commands "Script
Commands") »

#  mv command

[ Moves ](/eng/docs/task_move_duplicate) or renames one or more remote files.

  * Syntax 
  * Remarks 
  * Examples 
  * Converting to .NET Assembly 

##  Syntax

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

##  Remarks

Destination ` directory ` or ` newname ` or both must be specified.
Destination directory must end with slash. [ Operation mask
](/eng/docs/operation_mask) can be used instead of new name. Filename can be
replaced with [ wildcard ](/eng/docs/file_mask) to select multiple files.

Alias: ` rename `

Effective [ options ](/eng/docs/scriptcommand_option) : ` [ failonnomatch
](/eng/docs/scriptcommand_option#failonnomatch) `

XML  log element: ` [ mv ](/eng/docs/logging_xml#mv) `

_Advertisement_

##  Examples

    
    
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) index.html public_html/
    
    
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) index.html about.*
    
    
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) index.html public_html/about.*
    
    
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) public_html/index.html public_html/about.html /home/martin/*.bak
    
    
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) *.html /home/backup/*.bak

##  Converting to .NET Assembly

When [ converting script to .NET Assembly ](/eng/docs/library_from_script) ,
map ` mv ` command to ` [ Session.MoveFile
](/eng/docs/library_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 ](/eng/docs/library_from_script#paths) .

For example, following script snippet:

    
    
    [cd](https://winscp.net/eng/docs/scriptcommand_cd) /home/martinp
    [mv](https://winscp.net/eng/docs/scriptcommand_mv) public_html/index.html public_html/about.html *.bak

_Advertisement_

maps to following [ PowerShell ](/eng/docs/library_powershell) code:

    
    
    $session.MoveFile("/home/martinp/public_html/index.html", "/home/martinp/*.bak")
    $session.MoveFile("/home/martinp/public_html/about.html", "/home/martinp/*.bak")

##  Contribute

![PayPal](https://winscp-
static-746341.c.cdn77.org/assets/images/paypal.svg?v=7032)

[ Donate ](/eng/donate.php)

  * [ $9 ](/eng/donate.php?amount=9&currency=USD&class=S "Donate $9 via PayPal")
  * [ $19 ](/eng/donate.php?amount=19&currency=USD&class=S "Donate $19 via PayPal")
  * [ $49 ](/eng/donate.php?amount=49&currency=USD&class=S "Donate $49 via PayPal")
  * [ $99 ](/eng/donate.php?amount=99&currency=USD&class=S "Donate $99 via PayPal")

![Visa](https://winscp-static-746341.c.cdn77.org/assets/images/card-logo-
visa.svg?v=7032) ![Mastercard](https://winscp-
static-746341.c.cdn77.org/assets/images/card-logo-mastercard.svg?v=7032)
![American Express](https://winscp-
static-746341.c.cdn77.org/assets/images/card-logo-amex.svg?v=7032)
![Other](https://winscp-static-746341.c.cdn77.org/assets/images/card-logo-
unknown.svg?v=7032)

##  User Approved Software

###  Total Downloads:

214,431,241

###  Rating:

4.8  out of  195  reviews

[ SourceForge Review ](https://