OctOS: Add mv command

Allows moving files and directories.
master
octacian 2017-03-28 17:21:38 -07:00
parent cfc1bb4e79
commit dc6c24e669
3 changed files with 31 additions and 3 deletions

View File

@ -16,7 +16,7 @@ Create new file.
#### `rm [path]`
Remove file.
#### `cp [old path] [copy path]`
#### `cp [original path] [copy path]`
Make a copy of a file.
#### `mkdir [path]`
@ -25,5 +25,8 @@ Create new directory.
#### `rmdir [path]`
Remove directory.
#### `cpdir [old path] [copy path]`
Make a copy of a directory.
#### `cpdir [original path] [copy path]`
Make a copy of a directory.
#### `mv [old path] [new path]`
Move a file or directory to a new location.

4
octos/bin/mv Normal file
View File

@ -0,0 +1,4 @@
name = mv
description = Move a file or directory
params = [old path] [new path]
exec = os/exec/mv.lua

21
octos/exec/mv.lua Normal file
View File

@ -0,0 +1,21 @@
local path = ...
local old = path[1]
local new = path[2]
if old and new then
if fs.exists(old) then
if not fs.exists(new) then
if fs.cpdir(old, new) and fs.rmdir(old) then
print("Moved "..old.." to "..new)
else
print(old.." is a file")
end
else
print(new.." already exists")
end
else
print(old.." does not exist")
end
else
print("Must specify old and new path (see help mv)")
end