Differences

This shows you the differences between the selected revisions of the page.

scriptcommand_mv 2012-06-23 scriptcommand_mv 2020-05-29 (current)
Line 1: Line 1:
-====== mv ======+====== mv command ======
[[task_move_duplicate|Moves]] or renames one or more remote files. [[task_move_duplicate|Moves]] or renames one or more remote files.
 +
 +===== Syntax =====
  mv <file> [ <file2> ... ] [ <directory>/ ][ <newname> ]   mv <file> [ <file2> ... ] [ <directory>/ ][ <newname> ]
 +
 +===== Remarks =====
Destination ''directory'' or ''newname'' or both must be specified. Destination directory must end with slash. [[operation_mask|Operation mask]] can be used instead of new name. Filename can be replaced with [[file_mask|wildcard]] to select multiple files. Destination ''directory'' or ''newname'' or both must be specified. Destination directory must end with slash. [[operation_mask|Operation mask]] can be used instead of new name. Filename can be replaced with [[file_mask|wildcard]] to select multiple files.
Alias: ''rename'' Alias: ''rename''
 +
 +Effective [[scriptcommand_option|options]]: ''[[scriptcommand_option#failonnomatch|failonnomatch]]''
XML log element: ''[[logging_xml#mv|mv]]'' XML log element: ''[[logging_xml#mv|mv]]''
Line 15: Line 21:
<code winscp> <code winscp>
mv index.html public_html/ mv index.html public_html/
 +</code>
 +<code winscp>
mv index.html about.* mv index.html about.*
 +</code>
 +<code winscp>
mv index.html public_html/about.* mv index.html public_html/about.*
 +</code>
 +<code winscp>
mv public_html/index.html public_html/about.html /home/martin/*.bak mv public_html/index.html public_html/about.html /home/martin/*.bak
 +</code>
 +<code winscp>
mv *.html /home/backup/*.bak mv *.html /home/backup/*.bak
</code> </code>
 +===== [[net]] Converting to .NET Assembly =====
 +When [[library_from_script|converting script to .NET Assembly]], map ''mv'' command to ''[[library_session_movefile|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 [[library_from_script#paths|convert relative paths to absolute paths]].
 +
 +For example, following script snippet:
 +
 +<code winscp>
 +cd /home/martinp
 +mv public_html/index.html public_html/about.html *.bak
 +</code>
 +
 +maps to following [[library_powershell|PowerShell]] code:
 +
 +<code powershell>
 +$session.MoveFile("/home/martinp/public_html/index.html", "/home/martinp/*.bak")
 +$session.MoveFile("/home/martinp/public_html/about.html", "/home/martinp/*.bak")
 +</code>

Last modified: by Petr