Renaming folders?

maxdax5

Member
Can we rename folders? We can rename files or even create a new folder, copy all files in that new one and destroy the other one but before doing it i just want to be sure that we really cant rename folders/directories.

Why doing it? In working_directory my main folder is the version of the game and this is the one i want to rename.
 

rIKmAN

Member
Can we rename folders? We can rename files or even create a new folder, copy all files in that new one and destroy the other one but before doing it i just want to be sure that we really cant rename folders/directories.

Why doing it? In working_directory my main folder is the version of the game and this is the one i want to rename.
There are restrictions on writing files to the games directory with the native functions even when the sandbox is disabled.
This thread has more info, specifically the linked post of a reply from YYG regarding the issue: https://forum.yoyogames.com/index.p...ith-sandbox-disabled.67617/page-2#post-418018

You should be able to do it using the File Manager by Samual Venable: https://marketplace.yoyogames.com/assets/5510/file-manager
 

maxdax5

Member
I am having a hard time to make it work. directory_rename/copy(oldname,newname); But it give me 0 (failed) every time. Any idea what i could be doing wrong? i tried working_directory, game_save_id and even simply the name of the directory.
 
Last edited:

TsukaYuriko

☄️
Forum Staff
Moderator
If the absolute path doesn't work - do you have OS-level permissions to rename this folder? As in, does the application that is trying to change the folder (your game) have permissions to change that folder's name? Usually, folders in locations such as Program Files are protected and will require administrative elevation.
 

maxdax5

Member
Can anyone give me more info on how game_save_id work compare to working_directory? And also what is best using to find the path to the game folder? Like when a game is run with steam by example.
 

TsukaYuriko

☄️
Forum Staff
Moderator
game_save_id is the local storage, readable and writable and has probably the most unsuitable name out of everything in GML.
program_directory is the game's folder and is readable but not writable regardless of sandboxing.
 

maxdax5

Member
I did not knew about program_directory. Does having the .exe file inside the folder i want to edit make the path wrong?
EX: "Game_folder\version_2\"(exe in version_2). If i want to edit the version_2 or files in Game_folder i guess i cant use program_directory as path?
Does game_save_id would return "Game_folder"?
 

TsukaYuriko

☄️
Forum Staff
Moderator
game_save_id returns a folder in %APPDATA% or %LOCALAPPDATA% depending on your game's settings.

Did I understand this correctly? You're running something in Game_folder\version_2, and are trying to rename version_2.
If so, you'd be renaming a folder that contains a program that is currently running. That won't work under any circumstances.
 

maxdax5

Member
I just want to find the way to be certain that the path leads to "Game_folder". Best example is steam. Steam create a folder of your game. "common\game_name\version\exe....". To get the path of "game_folder" what would it be? Cause working_directory worked for me but for other things is dont. I am just trying to understand there exact meaning. And thx for your time!
 

TsukaYuriko

☄️
Forum Staff
Moderator
program_directory is the folder the game's .exe file resides in. If you want to find the folder one level higher, take a substring of it up to the last slash (or second to last if the last character is a slash).

Beware that Steam's library defaults to Program Files and will therefore likely not be accessible, though.
 
Top