Is there a way to merge Steam's screenshots.vdf from multiple computers into one?

Joined
Jan 3, 2009
Messages
648
I have been using Steam on multiple computers and want to merge all of my screenshots I have been taking on them into my main system. The screenshots themselves are not a problem, you basically just copy over the folder(s) and after a painstaking time of Steam going "New screenshot taken!" for hours as it sorts through all the new screenshots it finds they are integrated into your library.

The problem is however that there is also a file called "screenshots.vdf" that seems to be a catalog/list of all of your screenshots taken in Steam in the "C:\Program Files (x86)\Steam\userdata\[user_number_here]\760\" folder. While Steam does appear to update and append any new screenshots to this file, the issue is that this file also stores if you wrote any captions/comments for any of your screenshots in it, which do NOT carry over if you just simply copy over the folders containing the screenshots.

I want to try to preserve all the comments I wrote too, is there any way to do this? Seems like the only way would be to merge the contents of the screenshots.vdf files, but I am not aware of any tool that can do that. I tried Googling about it, and I saw several tools mentioned but none appear to be designed specifically to do this. SteaScree came up a lot but that appears to be for adding external screenshots into your library, it can add them to the screenshots.vdf file but it doesn't appear to read other screenshots.vdf files and merge/copy entries. GameSave Manager was another that came up (and one I have used many times before to backup my saves) where I read some sites says it specifically does this, but it does not. It just copies the folders over and completely leaves the screenshots.vdf file untouched.

The file itself appears to basically just be a text file, and is very easily human-readable if you open it up in a text editor such as Notepad and the way it is organized is obvious, but I am not aware of any tools designed to actually parse and edit this file in such a way that it can merge the entries from different ones together. Are there any tools or other ways to do this? I have several thousand screenshots across hundreds of games to merge so doing it manually is not at all feasible.
 
I took a quick stab at this and have a proof of concept. Not guaranteeing it's exactly correct/doesn't miss records yet since I'm too lazy to write tests now, but output seems at least somewhat sane at a glance.

I'll post the source and binaries in a bit and you can give it a try.
 
Attached a zip - probably not linking to my Github.

Binaries are under ./dist/.

Throw whatever files next to the binary, or if you're running from Python, in the current working directory. Name them like this:
screenshots1.vdf
screenshots2.vdf
screenshots3.vdf
...

It should (hopefully) barf out an aptly named output.txt file that is the merged output. I only hurled some dummy data I created at it, so let me know if it explodes or fails horribly for whatever you feed it.

As it merges things together, it tries to avoid duplicates and fix the indicies as it adds records.

1716175243145.png
 

Attachments

  • vdf-screenshot-merger.zip
    12.8 MB · Views: 0
I think I partially misread and may have a flaw in my logic. Of course I randomly thought of it while in bed.

I currently merge files and consider screenshot records unique based on filename. The filename itself is a timestamp and you probably won't collide under normal circumstances and I expect the tool will suffice for smashing these files together.

But, I think I misunderstood that your problem is that Steam effectively produced a new database for with all the files from you copying them over, but none of the metadata like comments is there from the other vdf - and that's what you want.

Am I understanding correctly?

If yes, I already handle everything to facilitate this. It should only be a minor tweak.
 
\Wow, I was not expecting someone to just write a program to do this. I was considering doing it but I am not a developer and would have had no idea how to start with parsing all the data to put it back in later. I'll round up the screenshot files from my different systems and see how it merges them later today once I've had some sleep.

I think I partially misread and may have a flaw in my logic. Of course I randomly thought of it while in bed.

I currently merge files and consider screenshot records unique based on filename. The filename itself is a timestamp and you probably won't collide under normal circumstances and I expect the tool will suffice for smashing these files together.

But, I think I misunderstood that your problem is that Steam effectively produced a new database for with all the files from you copying them over, but none of the metadata like comments is there from the other vdf - and that's what you want.

Am I understanding correctly?

If yes, I already handle everything to facilitate this. It should only be a minor tweak.

I don't think it's likely the files will have the same filename since they are based on a timestamp like you said, not like I could have been playing two games at the same time, much less take a screenshot in both at the exact same time.

And it didn't produce a new database, as in another screenshot.vdf file. It added the screenshots I copied to the existing database/screenshot.vdf file, just that it only included some basic information about the screenshot. A lot of the additional metadata, including any comments, is missing. This missing data seems to still appear in the Steam client itself IF the screenshot was uploaded to the cloud prior, but even in that case it will only appear in the cloud version and not in the local version or the database file. And yes, I want to merge all that metadata between multiple vdf files into one, especially the comments.

Steam has some documentation on using their Screenshot API, but it doesn't cover everything since this is documentation meant to help developers incorporate the API into their games, not a detailed explanation of every detail of how their Screenshot feature works:
https://partner.steamgames.com/doc/api/ISteamScreenshots

I have not gone through my vdf files with a fine toothed comb, but I have noticed some weirdness in some entries.

Here is the beginning of my one of my system's files for example:

View: https://i.imgur.com/SMmJzuo.png

You can see the first image has a comment, but not every field mentioned in that API documentation.

And this is another one I saw that struck me as odd:

View: https://i.imgur.com/DlOXJWr.png

Some games apparently save two screenshots, one in the Steam client and one for their own screenshot location. (I honestly had no idea any Steam games did this until yesterday)

Not even sure what to do if I have a different set of screenshots for the same game on two different systems that I want to merge. Just adding the entire block of data between the {} fields per game ID would not be hard, but if you have to merge two sets of entries for the same ID that can be confusing, especially since then how would you figure out what screenshot gets what number since it numbers each of them too, and then both databases would start with 0 but have completely different actual screenshots. No idea if changing their numbering would also somehow screw with the cloud version.
 
I already handle that case in your last paragraph. As long as the additional screenshots for a game have unique filenames, they will get merged in and their numbering in the vdf will be fixed appropriately so it continues sequentially.

I think this sequential numbering of screenshots in the file itself is just a convention of the file format and not particularly important - as in it won't confuse the cloud stuff.
 
Back
Top