This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SuicidalSTDz's profile picture

Forcefully renaming files?

Started by SuicidalSTDz, 20 January 2013 - 06:09 AM
SuicidalSTDz #1
Posted 20 January 2013 - 07:09 AM
The Code:
renameFile = true
if renameFile == true then
x = shell.getRunningProgram()
print("EnderOS is renaming this file to ."..x.." for your safety!")
[This is where it will pull the file name and change it, just can't figure out how to]
end
Any help is highly appreciated :)/>

Edit: Could I just do shell.run("rename",x,".(x)") ?
mibac138 #2
Posted 20 January 2013 - 07:15 AM

where = -- Where to move/rename
renameFile = true
if renameFile == true then
x = shell.getRunningProgram()
print("EnderOS is renaming this file to ."..x.." for your safety!")
fs.move(x, where)
end

I think so it works only add where directory (where = "X") :D/>
SuicidalSTDz #3
Posted 20 January 2013 - 07:16 AM

where = -- Where to move/rename
renameFile = true
if renameFile == true then
x = shell.getRunningProgram()
print("EnderOS is renaming this file to ."..x.." for your safety!")
fs.move(x, where)
end
But wouldn't I have to make a new file doing this? Or would it make the file whilst moving it
EDIT:
Ok I see now. Thanks alot
mibac138 #4
Posted 20 January 2013 - 07:18 AM
fs.move() delets the old file and creates new with the same content ;)/>

No problem! :)/>