Jump to content
  • 0

how to use os.rename


animehack

Question

4 answers to this question

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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')

 

Link to comment
Share on other sites

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.