Rename a file: Difference between revisions

Content added Content deleted
(Add Processing)
(→‎{{header|Processing}}: add root rename part of task)
Line 915: Line 915:
=={{header|Processing}}==
=={{header|Processing}}==
<lang processing>void setup(){
<lang processing>void setup(){
boolean sketchfile = rename(sketchPath("input.txt"), sketchPath("output.txt"));
// rename local file in sketch path
boolean sketchfold = rename(sketchPath("docs"), sketchPath("mydocs"));
String oldname = "input.txt";
// sketches will seldom have write permission to root files/folders
String newname = "output.txt";
boolean success = rename(sketchPath(oldname), sketchPath(newname));
boolean rootfile = rename("input.txt", "output.txt");
boolean rootfold = rename("docs", "mydocs");
println(oldname, newname, success);
// true if succeeded, false if failed

println(sketchfile, sketchfold, rootfile, rootfold);
// rename local folder in sketch path
oldname = "docs";
newname = "mydocs";
success = rename(sketchPath(oldname), sketchPath(newname));
println(oldname, newname, success);
}
}