Selecting used Footage

Hi folks,

I have made a small animal film from over 80 video clips selected from over 200 footage clips.

I would now like to select the clips used (in Timeline) from these (have them unfortunately in the same folder) as I would like to delete all the others. But also all those that are contained in the playlist (there were a few as an alternative but I didn’t use them).

I have looked at the export options, don’t know what is best here, where the difference is:

In the export section >
Timeline
Playlist
Each Playlist Item

Or File Menu > Export > EDL and then search out manually…?

Tanks for help

save a copy of the .mlt file to test.mlt
remove all elements from the playlist
in window open an powershell console in same directory as test.mlt
run the following to line to list all unique source files in test.mlt

get-content test.mlt | select-string -pattern '<property name="resource">(.*?)</property>' | ForEach-Object {$_.Matches.Groups[1].Value} | select-object -Unique

Wow, looks interesting, thanks a lot. I will test it after my journey tomorrow, reporting later.
I am doing this on Linux. But I just see a Powershell is from microsoft… mh…
And I wonder what is the expected output , if it works at all on Linux ?

@TimLau would the View > Resources tool in Shotcut work the same?

Before emptying the Playlist

shotcut_CGar5GH2oY

After emptying the Playlist

(the listed items in that one are all that is left in the Timeline)
shotcut_7r3ci9G5OU

1 Like

In Linux this will show filename ressources in test.mlt

cat test.mlt | grep -oP '(?<=<property name="resource">)[^<]+' | grep -P ".*?\.\w*"

Here is an python script to read the resources from test.mlt
and delete the files in the “footage” folder not found in the test.mlt

uncomment the unlink line to do the real deleting

import re
from pathlib import Path

mlt_file = "test.mlt"  # mlt files
res_dir = "footage"  # relative to mlt_file

resource_path = Path(mlt_file).parent / Path(res_dir)  # folder with clips

# regex to match video resource files
match_re = re.compile(r'<property name="resource">(.*\.\w*)</property>')

# build list of used resources
resources = set()
with open(mlt_file) as f:
    data = f.readlines()
for line in data:
    match = match_re.search(line)
    if match:
        resource_file = Path(match.group(1))
        if resource_file not in resources:
            resources.add(resource_file)
            print(f"found file : {resource_file}")


# check for unused resources
for resource in resource_path.glob("*.*"):
    if resource not in resources:
        print(f"delete : {resource}")
        # resource.unlink()
1 Like