Rename a file: Difference between revisions

Add NetRexx implementation
(Added F# version)
(Add NetRexx implementation)
Line 478:
S X=$ZF(-1,"rename [000000]input.txt [000000]output.txt")
S X=$ZF(-1,"rename [000000]docs.dir [000000]mydocs.dir")</lang>
 
=={{header|NetRexx}}==
<lang NetRexx>/* NetRexx */
options replace format comments java crossref symbols binary
 
runSample(arg)
return
 
-- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
method isFileRenamed(oldFile, newFile) public static returns boolean
fo = File(oldFile)
fn = File(newFile)
fRenamed = fo.renameTo(fn)
return fRenamed
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg files
if files = '' then files = 'input.txt output.txt F docs mydocs D /input.txt /output.txt F /docs /mydocs D'
loop while files.length > 0
parse files of nf ft files
select case(ft.upper())
when 'F' then do
ft = 'File'
end
when 'D' then do
ft = 'Directory'
end
otherwise do
ft = 'File'
end
end
if isFileRenamed(of, nf) then dl = 'renamed'
else dl = 'not renamed'
say ft ''''of'''' dl 'to' nf
end
 
return
</lang>
 
=={{header|NewLISP}}==
Anonymous user