Jump to content
  • 0

how to use os.rename


animehack

Question

Posted

ok look i tryed to look at the lua doc but it just dident explain it good i think so i was wondring if anyone cuold help me out and tell me how to use os.rename to rename the script name thx

4 answers to this question

Recommended Posts

Posted
On 7/9/2020 at 10:52 AM, MrXnuv3r said:

You do gg.getFile() first

 

example of anti-rename code


FileName = 'ScriptName.lua'
Dir = gg.getFile():match('^.+/')
File = gg.getFile():match('[^/]+$')

if File ~= FileName then
gg.alert('File Rename Is Detected')
os.rename(''..File..'',''..Dir..'/'..FileName..'')
gg.alert('Renamed')
return
end

gg.alert('Your Code Here')

 

ah yes that makes much more seens thx for the help

Posted
16 hours ago, MrXnuv3r said:

os.rename('oldname.lua','newname.lua')

dose it operate in the same directory as the script is located or how do i know where the script at do i do /emulated/0/Downloads/scipt.lua /emulated/0/Downloads/renamed_scipt.lua ??

Posted
2 hours ago, animehack said:

dose it operate in the same directory as the script is located or how do i know where the script at do i do /emulated/0/Downloads/scipt.lua /emulated/0/Downloads/renamed_scipt.lua ??

You do gg.getFile() first

 

example of anti-rename code

FileName = 'ScriptName.lua'
Dir = gg.getFile():match('^.+/')
File = gg.getFile():match('[^/]+$')

if File ~= FileName then
gg.alert('File Rename Is Detected')
os.rename(''..File..'',''..Dir..'/'..FileName..'')
gg.alert('Renamed')
return
end

gg.alert('Your Code Here')

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.