I got a full list of photo names to edit and I am too lazy to flag every photo so I want to write a program that automatically flags the photos so the only thing I have to do is to check the "show flagged photos box". The problem is that I can't find the files within the flags are saved. I tried with XMP files, but no flags are saved there.
Lightroom saves (just about) everything in its catalog file (
<whatever>.lrcat). This is a SQLite database, so you can in theory edit it to your heart's content. As the linked question notes, Adobe don't make the database structure public but it's been reversed engineered by some folks.
From looking at openroom, I'm going to guess you want the
pick column in the
Image table but I haven't tested this.
Back up your catalog file before editing it, you don't want to trash everything.