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

rename

Started by masqurade99, 17 June 2014 - 02:19 AM
masqurade99 #1
Posted 17 June 2014 - 04:19 AM
Is there a way by editing the startup file, to rename a file when the computer boots up? Quick question, just trying to create something for a server I play on.
Bomb Bloke #2
Posted 17 June 2014 - 04:24 AM
Sure, with fs.move():

fs.move("oldName","newName")

By the by, questions should be asked in Ask a Pro.
masqurade99 #3
Posted 17 June 2014 - 04:25 AM
Sure, with fs.move():

fs.move("oldName","newName")

By the by, questions should be asked in Ask a Pro.

Thank you.

My mistake, Hit the wrong tab.
Lyqyd #4
Posted 17 June 2014 - 06:52 AM
Moved to Ask a Pro.
sEi #5
Posted 17 June 2014 - 07:51 AM
The computer will always look for file named startup and run it if present unless there is a floppy diskdrive connected and the drive contains a floppy-disk with a file named startup, then that is the startup file run at computer boot instead.

But i more wanted to tell the tip that: You can delete the file you are running! So even the startup file can delete itself and create a new startup file, and so on.

This just for inspiration:

STARTUP

-- copy old startup
fs.copy("startup", "startup_bak")

-- formulate new startup
local text="-- This is the automagical created startup\n"
text=text..'print("Hello World")' -- note single quotes

-- save new startup
local f=fs.open("startup","w")
f.write(text)
f.close()

-- reboot
os.reboot()
Fetch this script (Polymorph startup):
pastebin get qtRCQKFr startup

(note: Engrish is not my native language)

/sEi
Edited on 17 June 2014 - 06:06 AM