Rename a file: Difference between revisions

m
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Minor tidy)
 
(8 intermediate revisions by 5 users not shown)
Line 462:
 
Sleep</syntaxhighlight>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
CFURLRef inputText, outputText, docs, myDocs
inputText = fn URLFileURLWithPath( @"~/Desktop/input.txt" )
outputText = fn URLFileURLWithPath( @"~/Desktop/output.txt" )
docs = fn URLFileURLWithPath( @"~/Desktop/docs/" )
myDocs = fn URLFileURLWithPath( @"~/Desktop/myDocs/" )
 
fn FileManagerMoveItemAtURL( inputText, outputText )
fn FileManagerMoveItemAtURL( docs, myDocs )
</syntaxhighlight>
 
 
=={{header|Go}}==
Line 660 ⟶ 674:
c:\docs successfully renamed to c:\mydocs
</pre>
 
=={{header|Lang}}==
{{libheader|lang-io-module}}
<syntaxhighlight lang="lang">
# Load the IO module
# Replace "<pathToIO.lm>" with the location where the io.lm Lang module was installed to without "<" and ">"
ln.loadModule(<pathToIO.lm>)
 
fp.rename = ($from, $to) -> {
$fileFrom = [[io]]::fp.openFile($from)
$fileTo = [[io]]::fp.openFile($to)
[[io]]::fp.rename($fileFrom, $fileTo)
[[io]]::fp.closeFile($fileFrom)
[[io]]::fp.closeFile($fileTo)
}
 
fp.rename(input.txt, output.txt)
fp.rename(/input.txt, /output.txt)
fp.rename(docs, mydocs)
fp.rename(/docs, /mydocs)
</syntaxhighlight>
 
=={{header|Lasso}}==
Line 795 ⟶ 832:
io.nl(Stderr, !IO),
io.set_exit_status(1, !IO).</syntaxhighlight>
 
=={{header|min}}==
{{works with|min|0.37.0}}
<syntaxhighlight lang="min">"input.txt" "output.txt" mv
"docs" "mydocs" mv
 
"/input.txt" "/output.txt" mv
"/docs" "/mydocs" mv</syntaxhighlight>
 
=={{header|MUMPS}}==
Line 1,001 ⟶ 1,046:
mv("/docs", "/mydocs");
}</syntaxhighlight>
 
=={{header|Plain English}}==
<syntaxhighlight lang="text">
To run:
Start up.
\ In the current working directory
Rename ".\input.txt" to ".\output.txt" in the file system.
Rename ".\docs\" to ".\mydocs\" in the file system.
\ In the filesystem root
Rename "C:\input.txt" to "C:\output.txt" in the file system.
Rename "C:\docs\" to "C:\mydocs\" in the file system.
Shut down.
</syntaxhighlight>
 
=={{header|Pop11}}==
Line 1,244 ⟶ 1,302:
</syntaxhighlight>
 
=={{header|RPL}}==
RPL’s tree file system is made of variables, which can contain either programs or data, and directories. Variables and directories handling features are basic.
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
PATH { HOME } == 1 ROT '''IFTE'''
→ old new here
≪ '''IF''' here NOT '''THEN''' PATH HOME '''END'''
'''IFERR''' old RCL '''THEN'''
new CRDIR PURGE
'''ELSE'''
new STO old PURGE '''END'''
'''IF''' here NOT '''THEN'''
2 OVER SIZE '''FOR''' j DUP j GET EVAL '''NEXT'''
DROP '''END'''
≫ ≫ ''''RNAME'''' STO
|
'''RNAME''' ''( ‘old’ ‘new’ boolean -- )''
Set ''here'' to true if already at root
Store arguments
Store current path in stack and go to the root
Detect if ''old'' is a directory by recalling its content
If yes, create ''new'' then delete ''old''
Otherwise, store content in ''new'', then delete ''old''
Go back to current directory
following the path in stack
Forget path
|}
{{in}}
<pre>
'Input' 'Output' 1 RNAME
'DOCS' 'MYDOCS' 0 RNAME
</pre>
The boolean argument indicates if the renaming must be achieved in the current directory (1) or at the root (0).
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">File.rename('input.txt', 'output.txt')
Line 1,474 ⟶ 1,572:
{{libheader|Wren-ioutil}}
Wren-cli does not currently have the ability to rename directories, just files.
<syntaxhighlight lang="ecmascriptwren">import "./ioutil" for FileUtil
 
FileUtil.move("input.txt", "output.txt")
Line 1,528 ⟶ 1,626:
{{omit from|Befunge}} <!-- No filesystem support -->
{{omit from|Brlcad}}
{{omit from|EasyLang}}
{{omit from|Lilypond}}
{{omit from|ML/I}}
9,476

edits