Copy File

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
MehdiZangenehBar
Posts: 114
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Copy File

Post by MehdiZangenehBar »

How we can copy / move a file using script?
User avatar
synthsin75
Posts: 10265
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Copy File

Post 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
User avatar
MehdiZangenehBar
Posts: 114
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: Copy File

Post 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?
User avatar
synthsin75
Posts: 10265
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Copy File

Post 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.
User avatar
MehdiZangenehBar
Posts: 114
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: Copy File

Post 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.
Post Reply