Jump to content




Forcefully renaming files?


  • You cannot reply to this topic
3 replies to this topic

#1 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

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)") ?

#2 mibac138

  • Members
  • 132 posts
  • LocationPoland

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

#3 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 20 January 2013 - 07:16 AM

View Postmibac138, on 20 January 2013 - 07:15 AM, said:

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

#4 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 20 January 2013 - 07:18 AM

fs.move() delets the old file and creates new with the same content ;)

No problem! :)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users