Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to move files or folders?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 202

PostPosted: Sun Sep 22, 2019 3:28 am    Post subject: How to move files or folders? Reply with quote

I want to know how to move files or folders from C disk to D disk.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Sun Sep 22, 2019 3:44 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 202

PostPosted: Sun Sep 22, 2019 4:02 am    Post subject: Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Sep 24, 2019 4:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3325

PostPosted: Wed Sep 25, 2019 12:47 am    Post subject: Re: How to move files or folders? Reply with quote

.lua wrote:
I want to know how to move files or folders from C disk to D disk.

Windows Explorer?
Total Commander?
Command line?
Very Happy

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
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Wed Sep 25, 2019 2:11 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3325

PostPosted: Wed Sep 25, 2019 2:51 am    Post subject: Reply with quote

Even better.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites