Page 1 of 1

Copy File

Posted: Sat Jun 29, 2024 10:54 pm
by MehdiZangenehBar
How we can copy / move a file using script?

Re: Copy File

Posted: Sun Jun 30, 2024 12:05 am
by synthsin75
Generally, you can use os.rename to change the path of a file: https://www.gammon.com.au/scripts/doc.php?lua=os.rename

Re: Copy File

Posted: Sun Jun 30, 2024 10:41 am
by MehdiZangenehBar
synthsin75 wrote: Sun Jun 30, 2024 12:05 am Generally, you can use os.rename to change the path of a file: https://www.gammon.com.au/scripts/doc.php?lua=os.rename
Thanks! what about copy? we can use cp command right?

Re: Copy File

Posted: Sun Jun 30, 2024 8:10 pm
by synthsin75
You can either read a file and write it to a new one using the Lua IO library, or use whatever commands are available using os.execute.
The latter option would have to take into account different OS commands.

Re: Copy File

Posted: Sun Jun 30, 2024 11:02 pm
by MehdiZangenehBar
synthsin75 wrote: Sun Jun 30, 2024 8:10 pm You can either read a file and write it to a new one using the Lua IO library, or use whatever commands are available using os.execute.
The latter option would have to take into account different OS commands.
Got it, Thanks.