option to unpack files to directory
It would be really handy if there was an option to unpack files to a directory, but before writing the file to the directory, it first checks the file doesn't already exist. If the file does exist, then it would check if the actual file data is identical. If it is identical, then it wouldn't bother saving (just update the file path in any image nodes), and if it isn't identical, the file would be saved under a different name, and any image nodes that used the texture, would be updated to use the new images filenames.
This means if your packed .blend files are taking up 100's of gigs of disk space, you could unpack them all to the same image directory, and reclaim disk space by getting rid of duplicate images without worrying if you have different images with the same name getting lost.
3 Comments
I would second this. I discovered that duplicate filenames will lead blender to discard texture files when you unpack. Testing has produced these results but I hope that I am just overlooking something. ( I am more than happy to be corrected on this ).
If you have different image files with the same filename, they get packed just fine. Blender will append a number as it does in other data blocks ( .001 .002 etc ).
When you unpack, however, Blender will write them all into that /textures folder but the behavior is not what you would expect. It will write all those files with their original names (that is, the same name) and do either of two things:
A: (No overwrite) Blender will unpack/write the first file. Then, it will not write subsequent (identically named) files since those subsequent files all have the name of a file already in existence at the destination. Those are now irretrievably gone and all materials that used them will point to the one that prevailed.
B:(Overwrite) Blender will write the first file, then overwrite that file with each subsequent name because the filename is the same (even though the contents are not).
Either way, you will forever lose n - (n-1) of n identically named image files.
Worse, right after the unpacking, all the files will still exist in memory, so you will still see them mapped on things in the viewport. It's not until you do a revert or a reload that you become aware that all but one of those identically named image files are now lost and un-recoverable. Additionally, all materials that contained those images now point to the one that prevailed. Your scene is broken.
"Unpack them to their original locations", some will say. I answer that this is rarely desired, if ever. The goal is self-containment and scattering an unknown number of random sets of files back into a filesystem is about as sloppy as file maintenance can get. Entire folder branches would be re-created that someone may have worked hard to prune in the days between packing and unpacking.
"Don't use image files that have identical names", other will say. That is pretty obvious but you will find in production that duplicate filenames, living in their own separate parts of the filesystem, are more common than you'd expect. Once or twice is enough for you to fall into this trap and there is, currently, zero way to (easily) check for it and zero remedy once found.
All Blender has to do is preserve the numeric suffixes and their association with Materials for this to be a non-issue. (That is when placing all textures into ./textures).
Did you find a temporary solution when I'm done with a project i unpack the textures to a new file but i can have different textures called diffuse and it thinks its the same image i don't know how to resolve this
I did not, actually. In my case, it was Character Creator initiating the trouble.
Many image maps are created for a new character and they have common names, like "Body_diffuse...", "Head_Normal..." etc.
If you have many characters in Blender, then pack them, you're fine. If you unpack them, though, you will either overwrite/ignore.
Ignore writes the first image and dutifully doesn't write all the rest.
Gone forever without warning or notice.
Overwrite dutifully overwrites each duplicate, leaving you only with the last one.
The rest are gone forever without warning or notice.
I've taken to adding a small prefix or suffix on each output (it can be anything). That makes the texture file names unique.