Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/Rename_a_file
note: File System Operations

View file

@ -0,0 +1,15 @@
;Task:
Rename:
:::*   a file called     '''input.txt'''     into     '''output.txt'''     and
:::*   a directory called     '''docs'''     into     '''mydocs'''.
This should be done twice:  
once "here", i.e. in the current working directory and once in the filesystem root.
It can be assumed that the user has the rights to do so.
(In unix-type systems, only the user root would have
sufficient permissions in the filesystem root.)
<br><br>

View file

@ -0,0 +1,5 @@
fs:rename(input.txt, output.txt)
fs:rename(docs, mydocs)
fs:rename(fs:path:sepinput.txt, fs:path:sepoutput.txt)
fs:rename(fs:path:sepdocs, fs:path:sepmydocs)

View file

@ -0,0 +1,22 @@
main:(
PROC rename = (STRING source name, dest name)INT:
BEGIN
FILE actual file;
INT errno = open(actual file, source name, stand back channel);
IF errno NE 0 THEN
errno
ELSE
IF reidf possible(actual file) THEN
reidf(actual file, dest name); # change the identification of the book #
errno
ELSE
close(actual file);
-1
FI
FI
END;
rename("input.txt", "output.txt");
rename("/input.txt", "/output.txt");
rename("docs", "mydocs");
rename("/docs", "/mydocs")
)

View file

@ -0,0 +1,4 @@
$ awk 'BEGIN{system("mv input.txt output.txt")}'
$ awk 'BEGIN{system("mv docs mydocs")}'
$ awk 'BEGIN{system("mv /input.txt /output.txt")}'
$ awk 'BEGIN{system("mv docs mydocs")}'

View file

@ -0,0 +1,33 @@
INCLUDE "D2:IO.ACT" ;from the Action! Tool Kit
PROC Dir(CHAR ARRAY filter)
BYTE dev=[1]
CHAR ARRAY line(255)
Close(dev)
Open(dev,filter,6)
DO
InputSD(dev,line)
PrintE(line)
IF line(0)=0 THEN
EXIT
FI
OD
Close(dev)
RETURN
PROC Main()
CHAR ARRAY filter="D:*.*",
cmd="D:INPUT.TXT OUTPUT.TXT"
Put(125) PutE() ;clear screen
PrintF("Dir ""%S""%E",filter)
Dir(filter)
PrintF("Rename ""%S""%E%E",cmd)
Rename(cmd)
PrintF("Dir ""%S""%E",filter)
Dir(filter)
RETURN

View file

@ -0,0 +1,6 @@
with Ada.Directories; use Ada.Directories;
...
Rename ("input.txt", "output.txt");
Rename ("docs", "mydocs");
Rename ("/input.txt", "/output.txt");
Rename ("/docs", "/mydocs");

View file

@ -0,0 +1 @@
RENAME INPUT.TXT,OUTPUT.TXT

View file

@ -0,0 +1 @@
10 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT"

View file

@ -0,0 +1,5 @@
10 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT"
20 PRINT CHR$ (4)"RENAME DOCS,MYDOCS"
30 PRINT CHR$ (4)"PREFIX /"
40 PRINT CHR$ (4)"RENAME INPUT.TXT,OUTPUT.TXT"
50 PRINT CHR$ (4)"RENAME DOCS,MYDOCS"

View file

@ -0,0 +1,13 @@
fileFrom: "input.txt"
fileTo: "output.txt"
docsFrom: "docs"
docsTo: "mydocs"
rename fileFrom fileTo
rename.directory docsFrom docsTo
rename join.path ["/" fileFrom]
join.path ["/" fileTo]
rename.directory join.path ["/" docsFrom]
join.path ["/" docsTo]

View file

@ -0,0 +1 @@
FileMove, oldname, newname

View file

@ -0,0 +1,4 @@
NAME "input.txt" AS "output.txt"
NAME "\input.txt" AS "\output.txt"
NAME "docs" AS "mydocs"
NAME "\docs" AS "\mydocs"

View file

@ -0,0 +1,4 @@
*RENAME input.txt output.txt
*RENAME \input.txt \output.txt
*RENAME docs. mydocs.
*RENAME \docs. \mydocs.

View file

@ -0,0 +1,4 @@
OSCLI "RENAME input.txt output.txt"
OSCLI "RENAME \input.txt \output.txt"
OSCLI "RENAME docs. mydocs."
OSCLI "RENAME \docs. \mydocs."

View file

@ -0,0 +1,4 @@
RENAME "input.txt" TO "output.txt"
RENAME "/input.txt" TO "/output.txt"
RENAME "docs" TO "mydocs"
RENAME "/docs" TO "/mydocs"

View file

@ -0,0 +1,4 @@
ren input.txt output.txt
ren \input.txt output.txt
ren docs mydocs
ren \docs mydocs

View file

@ -0,0 +1,4 @@
ren$("input.txt"."output.txt") { 'ren' is based on standard C function 'rename()' }
ren$(docs.mydocs) { No quotes needed: names don't contain dots or colons. }
ren$("d:\\input.txt"."d:\\output.txt") { Backslash is escape character, so we need to escape it. }
ren$(@"d:\docs".@"d:\mydocs") { @ used as syntactic sugar as in C# for inhibiting escape. }

View file

@ -0,0 +1,10 @@
#include <cstdio>
int main()
{
std::rename("input.txt", "output.txt");
std::rename("docs", "mydocs");
std::rename("/input.txt", "/output.txt");
std::rename("/docs", "/mydocs");
return 0;
}

View file

@ -0,0 +1,18 @@
#include "boost/filesystem.hpp"
int main()
{
boost::filesystem::rename(
boost::filesystem::path("input.txt"),
boost::filesystem::path("output.txt"));
boost::filesystem::rename(
boost::filesystem::path("docs"),
boost::filesystem::path("mydocs"));
boost::filesystem::rename(
boost::filesystem::path("/input.txt"),
boost::filesystem::path("/output.txt"));
boost::filesystem::rename(
boost::filesystem::path("/docs"),
boost::filesystem::path("/mydocs"));*/
return 0;
}

View file

@ -0,0 +1,12 @@
using System;
using System.IO;
class Program {
static void Main(string[] args) {
File.Move("input.txt","output.txt");
File.Move(@"\input.txt",@"\output.txt");
Directory.Move("docs","mydocs");
Directory.Move(@"\docs",@"\mydocs");
}
}

View file

@ -0,0 +1,10 @@
#include <stdio.h>
int main()
{
rename("input.txt", "output.txt");
rename("docs", "mydocs");
rename("/input.txt", "/output.txt");
rename("/docs", "/mydocs");
return 0;
}

View file

@ -0,0 +1,7 @@
FRename( "input.txt","output.txt")
or
RENAME input.txt TO output.txt
FRename("\input.txt","\output.txt")
or
RENAME \input.txt TO \output.txt

View file

@ -0,0 +1,11 @@
(import '(java.io File))
(.renameTo (File. "input.txt") (File. "output.txt"))
(.renameTo (File. "docs") (File. "mydocs"))
(.renameTo
(File. (str (File/separator) "input.txt"))
(File. (str (File/separator) "output.txt")))
(.renameTo
(File. (str (File/separator) "docs"))
(File. (str (File/separator) "mydocs")))

View file

@ -0,0 +1 @@
OPEN 15,<Device>,15,"R<DRIVE>:FilenameOLD=FilenameNEW":CLOSE 15

View file

@ -0,0 +1 @@
RENAME <FilenameOLD>[,D<DRIVE>] TO <FilenameNEW> [ON U<Deviceadress>]

View file

@ -0,0 +1,4 @@
(rename-file "input.txt" "output.txt")
(rename-file "docs" "mydocs")
(rename-file "/input.txt" "/output.txt")
(rename-file "/docs" "/mydocs")

View file

@ -0,0 +1,4 @@
std.file.rename("input.txt","output.txt");
std.file.rename("/input.txt","/output.txt");
std.file.rename("docs","mydocs");
std.file.rename("/docs","/mydocs");

View file

@ -0,0 +1,10 @@
XCALL RENAM ("output.txt","input.txt")
.IFDEF UNIX
XCALL SPAWN ("mv docs mydocs")
.ENDC
.IFDEF DOS
XCALL SPAWN ("ren docs mydocs")
.ENDC
.IFDEF VMS
XCALL SPAWN ("rename docs.dir mydocs.dir")
.ENDC

View file

@ -0,0 +1,4 @@
rename input.txt output.txt
rename docs.dir mydocs.dir
rename [000000]input.txt [000000]output.txt
rename [000000]docs.dir [000000]mydocs.dir

View file

@ -0,0 +1,14 @@
program RenameFile;
{$APPTYPE CONSOLE}
uses SysUtils;
begin
SysUtils.RenameFile('input.txt', 'output.txt');
SysUtils.RenameFile('\input.txt', '\output.txt');
// RenameFile works for both files and folders
SysUtils.RenameFile('docs', 'MyDocs');
SysUtils.RenameFile('\docs', '\MyDocs');
end.

View file

@ -0,0 +1,4 @@
for where in [<file:.>, <file:///>] {
where["input.txt"].renameTo(where["output.txt"], null)
where["docs"].renameTo(where["mydocs"], null)
}

View file

@ -0,0 +1,4 @@
File.rename "input.txt","output.txt"
File.rename "docs", "mydocs"
File.rename "/input.txt", "/output.txt"
File.rename "/docs", "/mydocs"

View file

@ -0,0 +1,4 @@
(rename-file "input.txt" "output.txt")
(rename-file "/input.txt" "/output.txt")
(rename-file "docs" "mydocs")
(rename-file "/docs" "/mydocs")

View file

@ -0,0 +1,4 @@
file:rename("input.txt","output.txt"),
file:rename( "docs", "mydocs" ),
file:rename( "/input.txt", "/output.txt" ),
file:rename( "/docs", "/mydocs" ).

View file

@ -0,0 +1,9 @@
open System.IO
[<EntryPoint>]
let main args =
File.Move("input.txt","output.txt")
File.Move(@"\input.txt",@"\output.txt")
Directory.Move("docs","mydocs")
Directory.Move(@"\docs",@"\mydocs")
0

View file

@ -0,0 +1,3 @@
"" "/" [
[ "input.txt" "output.txt" move-file "docs" "mydocs" move-file ] with-directory
] bi@

View file

@ -0,0 +1,12 @@
class Rename
{
public static Void main ()
{
// rename file/dir in current directory
File.rename("input.txt".toUri).rename("output.txt")
File.rename("docs/".toUri).rename("mydocs/")
// rename file/dir in root directory
File.rename("/input.txt".toUri).rename("/output.txt")
File.rename("/docs/".toUri).rename("/mydocs/")
}
}

View file

@ -0,0 +1,2 @@
s" input.txt" s" output.txt" rename-file throw
s" /input.txt" s" /output.txt" rename-file throw

View file

@ -0,0 +1,6 @@
PROGRAM EX_RENAME
CALL RENAME('input.txt','output.txt')
CALL RENAME('docs','mydocs')
CALL RENAME('/input.txt','/output.txt')
CALL RENAME('/docs','/mydocs')
END

View file

@ -0,0 +1,14 @@
' FB 1.05.0 Win64
Dim result As Long
result = Name("input.txt", "output.txt")
If result <> 0 Then
Print "Renaming file failed"
End If
result = Name("docs", "mydocs")
If result <> 0 Then
Print "Renaming directory failed"
End If
Sleep

View file

@ -0,0 +1,8 @@
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 )

View file

@ -0,0 +1,9 @@
package main
import "os"
func main() {
os.Rename("input.txt", "output.txt")
os.Rename("docs", "mydocs")
os.Rename("/input.txt", "/output.txt")
os.Rename("/docs", "/mydocs")
}

View file

@ -0,0 +1,5 @@
['input.txt':'output.txt', 'docs':'mydocs'].each { src, dst ->
['.', ''].each { dir ->
new File("$dir/$src").renameTo(new File("$dir/$dst"))
}
}

View file

@ -0,0 +1,5 @@
['input.txt':'output.txt', 'docs':'mydocs'].each { src, dst ->
['.', ''].each { dir ->
new AntBuilder().move(file:"$dir/$src", toFile:"$dir/$dst")
}
}

View file

@ -0,0 +1,5 @@
FRename( "input.txt","output.txt")
// or
RENAME input.txt TO output.txt
FRename( hb_ps() + "input.txt", hb_ps() + "output.txt")

View file

@ -0,0 +1,8 @@
import System.IO
import System.Directory
main = do
renameFile "input.txt" "output.txt"
renameDirectory "docs" "mydocs"
renameFile "/input.txt" "/output.txt"
renameDirectory "/docs" "/mydocs"

View file

@ -0,0 +1,7 @@
WRITE(FIle='input.txt', REName='.\output.txt')
SYSTEM(DIR='E:\HicEst\Rosetta')
WRITE(FIle='.\docs', REName='.\mydocs')
WRITE(FIle='\input.txt', REName='\output.txt')
SYSTEM(DIR='\')
WRITE(FIle='\docs', REName='\mydocs')

View file

@ -0,0 +1,4 @@
every dir := !["./","/"] do {
rename(f := dir || "input.txt", dir || "output.txt") |stop("failure for file rename ",f)
rename(f := dir || "docs", dir || "mydocs") |stop("failure for directory rename ",f)
}

View file

@ -0,0 +1,15 @@
// rename file in current directory
f := File with("input.txt")
f moveTo("output.txt")
// rename file in root directory
f := File with("/input.txt")
f moveTo("/output.txt")
// rename directory in current directory
d := Directory with("docs")
d moveTo("mydocs")
// rename directory in root directory
d := Directory with("/docs")
d moveTo("/mydocs")

View file

@ -0,0 +1,9 @@
frename=: 4 : 0
if. x -: y do. return. end.
if. IFUNIX do.
hostcmd=. [: 2!:0 '('"_ , ] , ' || true)'"_
hostcmd 'mv "',y,'" "',x,'"'
else.
'kernel32 MoveFileA i *c *c' 15!:0 y;x
end.
)

View file

@ -0,0 +1,4 @@
'output.txt' frename 'input.txt'
'/output.txt' frename '/input.txt'
'mydocs' frename 'docs'
'/mydocs' frename '/docs'

View file

@ -0,0 +1,26 @@
import java.io.File;
public class FileRenameTest {
public static boolean renameFile(String oldname, String newname) {
// File (or directory) with old name
File file = new File(oldname);
// File (or directory) with new name
File file2 = new File(newname);
// Rename file (or directory)
boolean success = file.renameTo(file2);
return success;
}
public static void test(String type, String oldname, String newname) {
System.out.println("The following " + type + " called " + oldname +
( renameFile(oldname, newname) ? " was renamed as " : " could not be renamed into ")
+ newname + "."
);
}
public static void main(String args[]) {
test("file", "input.txt", "output.txt");
test("file", File.separator + "input.txt", File.separator + "output.txt");
test("directory", "docs", "mydocs");
test("directory", File.separator + "docs" + File.separator, File.separator + "mydocs" + File.separator);
}
}

View file

@ -0,0 +1,5 @@
var fso = new ActiveXObject("Scripting.FileSystemObject")
fso.MoveFile("input.txt", "output.txt")
fso.MoveFile("c:/input.txt", "c:/output.txt")
fso.MoveFolder("docs", "mydocs")
fso.MoveFolder("c:/docs", "c:/mydocs")

View file

@ -0,0 +1,4 @@
"input.txt" "output.txt" frename
"/input.txt" "/output.txt" frename
"docs" "mydocs" frename
"/docs" "/mydocs" frename.

View file

@ -0,0 +1,9 @@
/* File rename, in jsish */
try { File.rename('input.txt', 'output.txt', false); } catch (str) { puts(str); }
exec('touch input.txt');
puts("overwrite set true if output.txt exists");
File.rename('input.txt', 'output.txt', true);
try { File.rename('docs', 'mydocs', false); } catch (str) { puts(str); }
try { File.rename('/docs', '/mydocs', false); } catch (str) { puts(str); }

View file

@ -0,0 +1,4 @@
mv("input.txt", "output.txt")
mv("docs", "mydocs")
mv("/input.txt", "/output.txt")
mv("/docs", "/mydocs")

View file

@ -0,0 +1,21 @@
// version 1.0.6
/* testing on Windows 10 which needs administrative privileges
to rename files in the root */
import java.io.File
fun main(args: Array<String>) {
val oldPaths = arrayOf("input.txt", "docs", "c:\\input.txt", "c:\\docs")
val newPaths = arrayOf("output.txt", "mydocs", "c:\\output.txt", "c:\\mydocs")
var oldFile: File
var newFile: File
for (i in 0 until oldPaths.size) {
oldFile = File(oldPaths[i])
newFile = File(newPaths[i])
if (oldFile.renameTo(newFile))
println("${oldPaths[i]} successfully renamed to ${newPaths[i]}")
else
println("${oldPaths[i]} could not be renamed")
}
}

View file

@ -0,0 +1,4 @@
(file:rename "input.txt" "output.txt")
(file:rename "docs" "mydocs")
(file:rename "/input.txt" "/output.txt")
(file:rename "/docs" "/mydocs")

View file

@ -0,0 +1,18 @@
# 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)

View file

@ -0,0 +1,17 @@
// move file
local(f = file('input.txt'))
#f->moveTo('output.txt')
#f->close
// move directory, just like a file
local(d = dir('docs'))
#d->moveTo('mydocs')
// move file in root file system (requires permissions at user OS level)
local(f = file('//input.txt'))
#f->moveTo('//output.txt')
#f->close
// move directory in root file system (requires permissions at user OS level)
local(d = file('//docs'))
#d->moveTo('//mydocs')

View file

@ -0,0 +1,10 @@
' LB has inbuilt 'name' command, but can also run batch files
nomainwin
name "input.txt" as "output.txt"
run "cmd.exe /c ren docs mydocs", HIDE
name "C:\input.txt" as "C:\output.txt"
run "cmd.exe /c ren C:\docs mydocs", HIDE
end

View file

@ -0,0 +1,4 @@
rename file "input.txt" to "output.txt"
rename folder "docs" to "mydocs"
rename file "/input.txt" to "/output.txt"
rename folder "/docs" to "/mydocs"

View file

@ -0,0 +1 @@
|ren,"input.txt","output.txt"

View file

@ -0,0 +1,4 @@
os.rename( "input.txt", "output.txt" )
os.rename( "/input.txt", "/output.txt" )
os.rename( "docs", "mydocs" )
os.rename( "/docs", "/mydocs" )

View file

@ -0,0 +1,10 @@
Module checkit {
Document A$={Alfa, beta}
Save.Doc A$, "this.aaa"
Print Exist("this.aaa")=true
dos "cd "+quote$(dir$)+" && del this.bbb", 100; ' using; to close dos window, and 100ms for waiting
Name this.aaa as this.bbb
Rem : Name "this.aaa" as "this.bbb" ' we can use strings or variables
Print Exist("this.bbb")=true
}
checkit

View file

@ -0,0 +1 @@
[STATUS, MSG, MSGID] = movefile (F1, F2);

View file

@ -0,0 +1,4 @@
-- Here
renameFile "input.txt" "output.txt"
-- Root
renameFile "/input.txt" "/output.txt"

View file

@ -0,0 +1,6 @@
;Local
S X=$ZF(-1,"rename input.txt output.txt")
S X=$ZF(-1,"rename docs.dir mydocs.dir")
;Root of current device
S X=$ZF(-1,"rename [000000]input.txt [000000]output.txt")
S X=$ZF(-1,"rename [000000]docs.dir [000000]mydocs.dir")

View file

@ -0,0 +1,6 @@
use FileTools in
Rename( "input.txt", "output.txt" );
Rename( "docs", "mydocs" );
Rename( "/input.txt", "/output.txt" ); # assuming permissions in /
Rename( "/docs", "/mydocs" ) # assuming permissions in /
end use:

View file

@ -0,0 +1,6 @@
SetDirectory[NotebookDirectory[]]
RenameFile["input.txt", "output.txt"]
RenameDirectory["docs", "mydocs"]
SetDirectory[$RootDirectory]
RenameFile["input.txt", "output.txt"]
RenameDirectory["docs", "mydocs"]

View file

@ -0,0 +1,34 @@
:- module rename_file.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module dir.
main(!IO) :-
rename_file("input.txt", "output.txt", !IO),
rename_file("docs", "mydocs", !IO),
rename_file("/input.txt", "/output.txt", !IO),
rename_file("/docs", "/mydocs", !IO).
:- pred rename_file(string::in, string::in, io::di, io::uo) is det.
rename_file(OldName, NewName, !IO) :-
io.rename_file(OldName, NewName, Result, !IO),
(
Result = ok
;
Result = error(Error),
print_io_error(Error, !IO)
).
:- pred print_io_error(io.error::in, io::di, io::uo) is det.
print_io_error(Error, !IO) :-
io.stderr_stream(Stderr, !IO),
io.write_string(Stderr, io.error_message(Error), !IO),
io.nl(Stderr, !IO),
io.set_exit_status(1, !IO).

View file

@ -0,0 +1,5 @@
"input.txt" "output.txt" mv
"docs" "mydocs" mv
"/input.txt" "/output.txt" mv
"/docs" "/mydocs" mv

View file

@ -0,0 +1,36 @@
/* 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
-- 09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)09:11, 27 August 2022 (UTC)~~
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

View file

@ -0,0 +1,4 @@
(rename-file "./input.txt" "./output.txt")
(rename-file "./docs" "./mydocs")
(rename-file "/input.txt" "/output.txt")
(rename-file "/docs" "/mydocs")

View file

@ -0,0 +1,7 @@
import os
moveFile("input.txt", "output.txt")
moveFile("docs", "mydocs")
moveFile(DirSep & "input.txt", DirSep & "output.txt")
moveFile(DirSep & "docs", DirSep & "mydocs")

View file

@ -0,0 +1,5 @@
let () =
Sys.rename "input.txt" "output.txt";
Sys.rename "docs" "mydocs";
Sys.rename "/input.txt" "/output.txt";
Sys.rename "/docs" "/mydocs";

View file

@ -0,0 +1,11 @@
use IO;
bundle Default {
class FileExample {
function : Main(args : String[]) ~ Nil {
File->Rename("input.txt", "output.txt");
File->Rename("docs", "mydocs");
File->Rename("/input.txt", "/output.txt");
File->Rename("/docs", "/mydocs");
}
}
}

View file

@ -0,0 +1,9 @@
NSFileManager *fm = [NSFileManager defaultManager];
// Pre-OS X 10.5
[fm movePath:@"input.txt" toPath:@"output.txt" handler:nil];
[fm movePath:@"docs" toPath:@"mydocs" handler:nil];
// OS X 10.5+
[fm moveItemAtPath:@"input.txt" toPath:@"output.txt" error:NULL];
[fm moveItemAtPath:@"docs" toPath:@"mydocs" error:NULL];

View file

@ -0,0 +1,3 @@
rename('docs','mydocs');
rename('input.txt','/output.txt');
rename('/docs','/mydocs');

View file

@ -0,0 +1,5 @@
OS-RENAME "input.txt" "output.txt".
OS-RENAME "docs" "mydocs".
OS-RENAME "/input.txt" "/output.txt".
OS-RENAME "/docs" "/mydocs".

View file

@ -0,0 +1,4 @@
system("mv input.txt output.txt");
system("mv /input.txt /output.txt");
system("mv docs mydocs");
system("mv /docs /mydocs");

View file

@ -0,0 +1,2 @@
install("rename","iss","rename");
rename("input.txt", "output.txt");

View file

@ -0,0 +1,6 @@
<?php
rename('input.txt', 'output.txt');
rename('docs', 'mydocs');
rename('/input.txt', '/output.txt');
rename('/docs', '/mydocs');
?>

View file

@ -0,0 +1,22 @@
var
f : file ; // Untyped file
begin
// as current directory
AssignFile(f,'input.doc');
Rename(f,'output.doc');
// as root directory
AssignFile(f,'\input.doc');
Rename(f,'\output.doc');
// rename a directory
AssignFile(f,'docs');
Rename(f,'mydocs');
//rename a directory off the root
AssignFile(f,'\docs');
Rename(f,'\mydocs');
end;

View file

@ -0,0 +1,8 @@
use File::Copy qw(move);
use File::Spec::Functions qw(catfile rootdir);
# here
move 'input.txt', 'output.txt';
move 'docs', 'mydocs';
# root dir
move (catfile rootdir, 'input.txt'), (catfile rootdir, 'output.txt');
move (catfile rootdir, 'docs'), (catfile rootdir, 'mydocs');

View file

@ -0,0 +1,7 @@
(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">rename_file</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"input.txt"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"output.txt"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">rename_file</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"docs"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"mydocs"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">rename_file</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"C:\\Copy.txt"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Copy.xxx"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">rename_file</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"C:\\docs"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"C:\\mydocs"</span><span style="color: #0000FF;">)</span>
<!--

View file

@ -0,0 +1,7 @@
_platform "windows" == if "\\" "ren " else "/" "mv " endif
var com var slash
com "input.txt output.txt" chain cmd
com "docs mydocs" chain cmd
com slash chain "input.txt " chain slash chain "output.txt" chain cmd
com slash chain "docs " chain slash chain "mydocs" chain cmd

View file

@ -0,0 +1,4 @@
(call 'mv "input.txt" "output.txt")
(call 'mv "docs" "mydocs")
(call 'mv "/input.txt" "/output.txt")
(call 'mv "/docs" "/mydocs")

View file

@ -0,0 +1,6 @@
int main(){
mv("input.txt", "output.txt");
mv("/input.txt", "/output.txt");
mv("docs", "mydocs");
mv("/docs", "/mydocs");
}

View file

@ -0,0 +1,9 @@
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.

View file

@ -0,0 +1,4 @@
sys_file_move('inputs.txt', 'output.txt');
sys_file_move('docs', 'mydocs');
sys_file_move('/inputs.txt', '/output.txt');
sys_file_move(/'docs', '/mydocs');

View file

@ -0,0 +1,4 @@
Rename-Item input.txt output.txt
# The Rename-item has the alias ren
ren input.txt output.txt

View file

@ -0,0 +1,2 @@
rename input.txt to output.txt
rename docs to mydocs

View file

@ -0,0 +1,19 @@
void setup(){
boolean sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"));
boolean sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"));
// sketches will seldom have write permission to root files/folders
boolean rootfile = rename("input.txt", "output.txt");
boolean rootfold = rename("docs", "mydocs");
// true if succeeded, false if failed
println(sketchfile, sketchfold, rootfile, rootfold);
}
boolean rename(String oldname, String newname) {
// File (or directory) with old name
File file = new File(oldname);
// File (or directory) with new name
File file2 = new File(newname);
// Rename file (or directory)
boolean success = file.renameTo(file2);
return success;
}

View file

@ -0,0 +1,29 @@
from java.io import File
def setup():
# rename local file
sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"))
# rename local folder
sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"))
# rename root file (if permitted)
rootfile = rename("input.txt", "output.txt")
# rename root folder (if permitted)
rootfold = rename("docs", "mydocs")
# display results of four operations: True=success, False=fail
println(str(sketchfile) + ' ' +
str(sketchfold) + ' ' +
str(rootfile) + ' ' +
str(rootfold))
# output:
# True True False False
def rename(oldname, newname):
# File (or directory) with old name
file = File(oldname)
# File (or directory) with new name
file2 = File(newname)
# Rename file (or directory)
success = file.renameTo(file2)
return success

View file

@ -0,0 +1,5 @@
RenameFile("input.txt", "output.txt")
RenameFile("docs\", "mydocs\")
RenameFile("/input.txt","/output.txt")
RenameFile("/docs\","/mydocs\")

View file

@ -0,0 +1,7 @@
import os
os.rename("input.txt", "output.txt")
os.rename("docs", "mydocs")
os.rename(os.sep + "input.txt", os.sep + "output.txt")
os.rename(os.sep + "docs", os.sep + "mydocs")

View file

@ -0,0 +1,7 @@
import shutil
shutil.move("input.txt", "output.txt")
shutil.move("docs", "mydocs")
shutil.move("/input.txt", "/output.txt")
shutil.move("/docs", "/mydocs")

View file

@ -0,0 +1,23 @@
$ "
import os
if os.path.exists('input.txt'):
os.rename('input.txt', 'output.txt')
" python
$ "
import os
if os.path.exists('docs'):
os.rename('docs', 'mydocs')
" python
$ "
import os
if os.path.exists('/input.txt'):
os.rename('/input.txt', '/output.txt')
" python
$ "
import os
if os.path.exists('/docs'):
os.rename('/docs', '/mydocs')
" python

Some files were not shown because too many files have changed in this diff Show more