View previous topic :: View next topic |
Author |
Message |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Sun Sep 22, 2019 3:28 am Post subject: How to move files or folders? |
|
|
I want to know how to move files or folders from C disk to D disk.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Sun Sep 22, 2019 3:44 am Post subject: |
|
|
get all filenames in the folder
then in the other folder create new files and read from the old file and write to the new file
once all are copied you can delete the old file
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Sun Sep 22, 2019 4:02 am Post subject: |
|
|
Dark Byte wrote: | get all filenames in the folder
then in the other folder create new files and read from the old file and write to the new file
once all are copied you can delete the old file | The compiled program will have a running directory. I want to move the files to this directory. When I close the program, it can delete the files automatically. I don't want to copy the files and write code to delete them.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue Sep 24, 2019 4:40 pm Post subject: |
|
|
Lua itself doesn't offer any real/great way of doing this cleanly. You can two (in stock Lua) basically two methods:
1. Read/write each file again and then delete the originals. You can do this by using the 'io' namespace to open, read, then rewrite the file in the new location. Then you can use 'os.remove' to delete the original file after it's been written to the new location.
2. You can abuse 'os.execute' or 'io.popen' to execute system level commands like a batch script. That way you can use something like xcopy instead or similar.
If you have the interest to do it, you can also go get LuaFileSystem or similar and compile it for CE's Lua implementation.
_________________
- Retired. |
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3325
|
Posted: Wed Sep 25, 2019 12:47 am Post subject: Re: How to move files or folders? |
|
|
.lua wrote: | I want to know how to move files or folders from C disk to D disk. |
Windows Explorer?
Total Commander?
Command line?
On the note of the command line though: some languages can invoke a system command that executes a command line type of call.
Not sure if CE allows that, but if it does, you can simply create the source and target dir strings in LUA and pass it as a system("copy src dest") command (and another one for del.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Wed Sep 25, 2019 2:11 am Post subject: |
|
|
Or use the "MOVE" command
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3325
|
Posted: Wed Sep 25, 2019 2:51 am Post subject: |
|
|
Even better.
|
|
Back to top |
|
 |
|