How to move files from one directory to the other with DirAccess

Godot Version

4.2

Question

I’m working on my save system and I want to move some files from a temporary folder to the save folder. However no matter what I do I cant seem to get the files to move. Everything I have tried has resulted in an error or the script works but the files haven’t changed locations.

	var tempDir = DirAccess.open("user://HINATempFolder")
	print(tempDir.get_files())
	var tempfiles = tempDir.get_files()
	var s: Array[String]
	s.assign(tempfiles)
	for i in s.size():
		tempDir.copy("user://HINATempFolder/" +s[i], 
"HINASaveFolder")

This the relevant code. The folders do exist and are created if they don’t in another part of the code.

The documentation says this for the copy function

Both arguments should be paths to files, either relative or absolute.

You should add the name of the file to the destination as well.

THANK YOUU SO MUCH! I dont know how I missed that.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.