Scan is not updating file pathnames

Hello friends,

I’m a Mac user and not terribly Linux/Docker savvy so when I learned of Stash I chose path of least resistance for me and installed it on my MacBook Pro, despite my Plex library being on my Asustor NAS. Everything seemed to work fine at least in Stash, but I ran into a big roadblock when it came to the syncing the metadata to Plex. It seems filepath remapping is an issue so I finally installed Stash on the NAS, moved Stash files over, edited the config.yml for the now correct pathnames.

The threads on the board here say to just scan the files and Stash will recognize the scene and update the new file path. It is not doing that for me. It is adding them as new files. I was still in the process of using Tagger to identify scenes, and looking at scenes with the Organized tag, pathnames have not changed and my scene count has doubled.

It sounds like Stash will match moved scenes by comparing PHashes. I haven’t moved my library, I’ve moved Stash. But I guess from Stash’s perspective I have moved my libraries. When I rescanned I turned off all of the ‘Generate’ tasks. Does it need to have Stash generate a PHash for the “moved” video in order for it to match it to the existing one already in its database?

If I have to go through Tagger again I guess at least I don’t have to reenter Performers and Studios but I’d prefer not to have to have to do that if this is fixable.

Stash matches moved scenes by comparing oshashes, which are based solely on the file conents.

If you transcoded or remuxed your files, this would break the oshash match.

otherwise, I’ve ran into but haven’t verified or tested that if you have the original library missing or removed, it won’t detect the removal or something along those lines. try adding your “old library” path back, and especially watch the logs to see if it gives you any errors

Oh that’s probably it. I was concurrently processing my entire library through Tdarr as well. I found both apps around the same time. My old library path is no longer valid. Mac’s point to /Volume/Share and the NAS points to /Volume 1/Share.

I don’t suppose there’s away to go into our Stash database and edit the entries manually? Do a search and replace? I just want to remap the Path from /Volumes/Plex to /Volume 1/Plex

This might be possible, but because the file contents are different, I’d be worried that some information might not be recomputed and that this could cause strange issues down the road. I haven’t looked at the code, but as an example, oshash probably wouldn’t be recomputed after a low-level database edit, and audio_codec and video_codec might not be either.


I was in a similar situation after a bulk transcode and wrote (with a lot of help from an LLM because I’m lazy) a Python script to merge all of the matching scenes, where matching is done based on file path + phash + duration.

The script makes some assumptions that are very specific to my exact setup, so it’s not something that I’d want to share right now, but if folks are super interested, I might be able to generalize it a bit and share.

Important for anyone who wants to do an implementation: The SceneMerge operation in Stash’s GraphQL API doesn’t merge most fields, such as tags and performers, so a lot of the merging must be done manually in the script.


If your library is small-ish, you could probably also use the built in duplicate scene finder to do merges, but that requires a few clicks per scene pair.

i would love to see a copy of this script. I understand that its specific to your setup, but if you ever get around to sharing it, I would love to see it, to use as a starting point for my stuff. I’m trying to do matches based on similar, Path and Name and phash, but am not very good at that stuff without a starting point. Usually if someone has done it and I know what they were trying to do, I can try and reverse engineer to the point it matches my setup and then move it forward

thanks

aaron

1 Like

If you are just trying to attach all the metadata from one path to all the files structured the same in another path you can edit the sqlite with something like db browser. Just go to the folders table and change the path from the old to the new one. Stash wont update anything other than the file location for the exact folder changed. Of course backup your database before trying this.