Managing resource subfolders using hard links

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Originally posted at Hime Works

Your project by default has a number of resource folders, stored in the Audio and Graphics folders such as Pictures, Battlers, BGM, and SE. However, if you have a large project, you may find yourself possibly having thousands of files in certain folders, making it difficult to manage your resources.

You may consider organizing your files into subfolders grouped based on some logical classification scheme, but the problem with this approach is that the editor has hardcoded the resource folders and does not recognize any new ones. This is not an issue for scripts using custom folders, but if you want to use the event editor to show pictures or use the database editor to assign battler sprites it wouldn't work.

However, with the use of "hard links", it is possible to to organize your resources in your own folders while developing your game.

Required

Hard links are available in Windows Vista and above without requiring any additional tools. If you are using older systems or non-windows systems, you will need to figure out the syntax for creating hard links there.

Background

If you don't know what a hard link is, you can read about it on wiki.

Problem

Suppose you have decided to organize your Tilesets folder like this:



However when you try to create a new tileset, you will find that the editor doesn't see any of your custom resources.



So now you have separate subfolders containing your resources, but the problem is that the editor only reads from the main Tilesets folder.

Solution

The trick is to create hard links with the following steps

1. Get this batch file: download. You can create your own with this code:

@echo offSetlocal EnableDelayedExpansionfor /R %%F in (*) do ( rem # make the filename set _name=%%~fF set _name=!_name:%cd%\=! set _name=!_name:\=-! rem # create hard link if it doesn't exist if not "%%~dpF"=="%cd%\" ( if not exist !_name! ( mklink /H "!_name!" "%%F" ) ))2. Place the file in the main resource folder (eg: Tilesets).3. Double-click the file to run the script.



When the script has finished executing, your folder will contain a bunch of files that were in the subfolders, automatically prefixed with the folder names. This may look like a simple copy and paste, but the difference is that the new files and the files in the subfolders point to the same data.



Now you can use them in your editor as usual



You can even have files with duplicate names as long as they are in separate folders.

Modifying existing resources

When you modify one of the resources in the subfolders, you will notice that the file with the same in the main folder has also changed automatically. This allows you to only work with your resources in the subfolders and not have to worry about the files in the main folder.

Adding new resources

When you add a new resource to a subfolder, it does not automatically get added to the main folder. Simply run the batch script again to create new hard links.

Publishing your game

Notice that the hard links actually take up space, so you will use up double the space just to develop your game. However, when you are ready to distribute your game, you can simply delete all of your subfolders and then pack up the game.
 
Last edited by a moderator:

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
Exactly what I was looking for!!!.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
However, when you are ready to distribute your game, you can simply delete all of your subfolders and then pack up the game.
What subfolders would you be deleting - the Indoor and Outdoor subfolders under Tilesest? Doesn't that just leave you with what the editor does by default - everything in a single folder?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
What subfolders would you be deleting - the Indoor and Outdoor subfolders under Tilesest? Doesn't that just leave you with what the editor does by default - everything in a single folder?
I don't know when this might be used. I just thought it was an interesting application of hard links and a batch file for flattening directories.


If you like to store your things in separate folders and you have name conflicts, you can use this to preserve your folder structure as well since the folder names are automatically attached to the filename of the linked files.


I am not too sure.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top