• Editor
  • Changing a folder and images path

Hi,

Some background of my use case:

Happens that I have two skeletons, one for characters and one for scenario. I setup the folders to pack so theres a "main folder", where I have some images of characters for frame animations, a subdirectory on the main folder called "SpineCharacters" that I use for the character skeleton, and another subdirectory on the main folder called "Scenario" so I use that for the scenario skeleton.

Then, with libgdx TexturePacker I pack the "main folder" with combineSubDirectories set to true, so I have one atlas for all objects (characters, scenario, etc, all in one atlas).

But, I encountered a problem with this setup. I wanted to use some images from the "Scenario" folder with my characters skeleton, so I have to change the Images folder in Spine to the "main folder" to use the Scenario folder... and yes, it doesn't find ALL the images for the skeleton, which is normal.

I already created a lot of Skins, so changing every single image to the new setup (adding a relative path to every image or assigning again all the images) isn't an option. So, I changed the Images folder to "Scenario" for a while, used the images that I wanted, and then changed again to "SpineCharacters" folder, so every image is found except the ones that I use from the "Scenario" folder.

This way, the regions would be found from the atlas, even if they aren't seen on Spine. BUT... it would be nice if there's an easy way to change the directory and fix the folder for every image to a relative one, because I will have to be changing the folder everytime I need to update that skeleton 😛

Not really urgent, but would save some time for those that... well... doesn't plan their images directories right .___.

Related Discussions
...

If you change the image folder you can quickly use Find and Replace to change the path of your images.

HTTPS をサポートしていないため、画像は非表示になっています。 | まだ表示する

Ah... Yeah, I tried that option but I don't have a keyword to find. For example, using SpineCharacters folder, when I assigned the images, one would have the name "head".

But, when I change to the main folder, if I assign an image from the same folder it has the name "SpineCharacters/head" (I have to add SpineCharacters/ before the name of every assigned image, so I think changing the Path field of the image is better, because it is blank right now)

That's fine, but I couldn't find a way to replace the path of an image (or their name) without introducing some text on the Find Textbox. Maybe allow it so if we select the "path" option on the Field list, we can replace without introducing some text? That would be enough.

I'm also curious about how to do this.

It's also useful for when you want several skeletons to share an atlas but some images for those different skeletons have the same filename.

I'm not super clear on the use case. Why don't you set a single images path and then use all images relative to that?

For Pharan's use case you'd have "images/skeleton1/head.png" and "images/skeleton2/head.png". If you want them in the same atlas then pack "images" with "Combine subdirectories" checked.

I don't know if it's applicable to your use case, but if using Find and Replace you can add something to the beginning using regex. Search for "(.)" without the quotes. The "." matches everything and the parenthesis define a group. Replace with "moo/$1" without the quotes. The $1 is replaced by the first group (which as you remember is everything that was found). Eg, this would replace "head" with "moo/head". Google or post here if you need help defining a regex to match something else.

I'm familiar with the combine subdirectories feature.

What I need to know is how to batch-reassign all the existing attachment paths to new paths. (Which you answered, thanks! That's a really useful set of four characters.)

Man, the wonders of regex, if only I understood how to use it.

Regex is very cool. It looks cryptic, but it is not hard to write your own. I'll ramble some basics:

  • . Dot matches any character. "a..d" matches a then any character then any character then d.

  • [xyz] Square brackets match any character in the brackets. "a[xyzb]cd" matches a then x,y,z or b then c then d.

  • * Asterisk means zero or more of the match before. "abcd" matches a then zero or more b's, then c then d.

  • + means one or more of the match before. "ab+cd" matches a then one or more b's, then c then d.

  • ^ means start. "abcd" matches abcd but only at the start of the input. "mooabcd" would not match.

  • $ means end. "abcd$" matches abcd but only at the end of the input. "abcdmoo" would not match.

  • [xyz] Square brackets with ^ as the first character match any character NOT in the brackets. "a[xyz]cd" matches a then any character not x,y or z then c then d.

  • It is common to use this pattern: "a[a]*a" this matches a, then zero or more characters that aren't, then a.

  • [0-9] You can use a range within the brackets. "[0-9]+" matches one or more digits. "[a-zA-Z]+" matches one or more lowercase or capital letter.

  • Groups are defined by parenthesis they aren't in the match. "(.+)" matches one or more of any character and stores it in group 1.

  • Groups are numbered by opening paren. "(a.(.))" matches a then any character then zero or more characters. Group 1 stores the whole match, group 2 stores only the zero or more characters.

  • Groups can be used in the replacement. "a(.)c" matches a then any character then c. If "abc" is replaced with "x$1z" then you get "xbz" because $1 is replaced with the group.

  • If you want to use a character that is special, then you need a backslash in front. Eg "a.png" matches a then any character then png. "a.png" matches a then dot then png.

Experiment in the find and replace dialog. Regex is cool!

Pop quiz, what does this match?

^\"([^-]+)-(.*)\"$

:nerd:

Maybe it would match something like this? "(-.*)" 😃

Thanks, didn't know that with a regex I would add a folder at the beginning of the path, problem solved 🙂

Would it match something like this?
"ashjklgaghalksghkighuskjvhasdjkgh


5635-63-636-3464-"

I like this game.
Thanks, Nate. I credit you for making me finally understand RegEx.


Nate...

(.*) doesn't seem to work. It returns 0 results. 😢

. kinda does the trick though.

.* matches everything, so if your replace textbox is empty you are trying to set everything's name to an empty string, which is not valid. I will make it show up as a red match that needs to be corrected.

Ah, I see.

Good thing you taught me regex, or I wouldn't have thought to use . at all. XD