How to copy a file from absolute location to res:// folder location using GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dlipdhunter
:warning: Old Version Published before Godot 3 was released.

Hi, I am trying to create a plugin to import/create tileset from sprite image. I want to make sure that the chosen sprite file resides in the res:// folder. If it is not, then I want to copy the sprite file to res:// folder. I checked the GDScript help file, but I couldn’t find any method for this. Can anyone share how you will copy a file from one location to another in GDScript?

Thanks in advance.

:bust_in_silhouette: Reply From: tiernich

already try:

Error copy( String from, String to) ?

type copy in the search help in the script tab to see.

Example use:

var dir = Directory.new()
dir.copy("res://files/sprite_image.tex", "res://sprite_image.tex")

sandheaver | 2017-07-16 19:11