Rename a file: Difference between revisions

m (added whitespace before the TOC (table of contents), added a ;Task: (bold) header, added other whitespace and highlighting to the task's preamble.)
Line 1,190:
rename, "docs", "mydocs";
rename, "/docs", "/mydocs";</lang>
 
=={{header|zkl}}==
Tested on Linux and Windows 10.
{{out}}
<pre>
ls -ld input.txt docs output.txt mydocs
ls: cannot access 'output.txt': No such file or directory
ls: cannot access 'mydocs': No such file or directory
drwxr-xr-x 2 craigd craigd 4096 Aug 10 16:24 docs
-rw-r--r-- 1 craigd craigd 0 Aug 10 16:24 input.txt
$ zkl
zkl: File.rename("input.txt","output.txt")
True
zkl: File.rename("docs","mydocs")
True
zkl: ^D
$ ls -ld input.txt docs output.txt mydocs
ls: cannot access 'input.txt': No such file or directory
ls: cannot access 'docs': No such file or directory
drwxr-xr-x 2 craigd craigd 4096 Aug 10 16:24 mydocs
-rw-r--r-- 1 craigd craigd 0 Aug 10 16:24 output.txt
</pre>
If don't have permissions (amongst other things):
<pre>
zkl: File.rename("/input.txt","/output.txt")
Exception thrown: IOError(rename(/input.txt,/output.txt): Permission denied)
</pre>
 
 
Anonymous user