Delete video file but keep scene

Sometimes I would like to delete the video file for a scene but keep the scene itself. It looks like that is not possible currently? There is no delete button for a scene’s last file. (However it is possible to create a scene with no associated files, just not apparently a way to get back to that state)

Use case: I have decided I don’t like the scene and don’t want to waste space keeping it. However, I want to keep the scene as a reference, so that I remember I didn’t like it / won’t download it again / can keep notes or tags on why I didn’t like it.

The hack to achieve this is to create a fileless scene and merge into it. :person_facepalming:

But doesn’t merging it add the file to the scene? I must be misunderstanding something

It does. Not sure what I was thinking.

3 Likes

Oh very cool! I did it by simply removing the local file and it works the same. I had to go through various directories tho.

Tangentially, is there a way to open folder in explorer where the file is located?

Tangentially, is there a way to open folder in explorer where the file is located?

You can probably modify this plugin to do that, or perhaps use it directly by making a batch file that opens explorer with the argument:

I made a script with the help of AI to remove split the file from the scene. Tag the scenes you want to split with ‘To Delete’ tag and then just run the script. Don’t forget to point to the path of your sqlite database:

conn = sqlite3.connect('path/to/stash-go.sqlite')

Script:

import sqlite3

# Connect to the SQLite database
conn = sqlite3.connect('path/to/stash-go.sqlite')
cursor = conn.cursor()

try:
    # Find the ID of the 'To Delete' tag from the 'tags' table
    cursor.execute("SELECT id FROM tags WHERE name = 'To Delete'")
    tag_id = cursor.fetchone()
    
    if not tag_id:
        print("No 'To Delete' tag found in the 'tags' table.")
        exit()
    
    tag_id = tag_id[0]

    # Find all scene_ids associated with the 'To Delete' tag from the 'scenes_tags' table
    cursor.execute("SELECT scene_id FROM scenes_tags WHERE tag_id = ?", (tag_id,))
    scene_ids = cursor.fetchall()

    # Extract the scene_ids from the result set
    scene_ids = [scene_id[0] for scene_id in scene_ids]

    if scene_ids:
        # Delete files properties associated with the scene_ids from the 'scenes_files' table
        for scene_id in scene_ids:
            cursor.execute("DELETE FROM scenes_files WHERE scene_id = ?", (scene_id,))
        
        # Remove the 'To Delete' tag from the 'scenes_tags' table for the affected scenes
        for scene_id in scene_ids:
            cursor.execute("DELETE FROM scenes_tags WHERE scene_id = ? AND tag_id = ?", (scene_id, tag_id))

        # Commit the changes to the database
        conn.commit()

        print("Deleted properties from 'scenes_files' table and removed 'To Delete' tag for scene IDs:", scene_ids)
    else:
        print("No scene IDs found for the 'To Delete' tag.")

except sqlite3.Error as e:
    print("Error:", e)

finally:
    # Close the database connection
    conn.close()

Oh interesting I’ll keep that in mind! Looks like the script doesn’t delete the actual file from disk?

No, it only splits the file from the scene.