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…?
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
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 ?
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()
First I want to apologize for the late respond, was travelling.
Thanks a lot for that script, it took me some time to run it, adjusting to my long path names.
Unfortunately it puts files on delete which are also in the found file list… and definitely being used in the .mlt file.
Interestingly some of the entries in the found file list have a number in front of the path, like 1.18:/home/rolf/longer path…
It’s the speed adjustment I had applied, and if a clip is used multiple time it’s listed the same times.
I have tried to figure out what could be the reason for files on delete which are used in mlt… thought its my file naming which I had put to some files additionally to the default given name like
VID_20240329_100447crowing.mp4 …
but even some of the default named files (VID_20240328_085948.mp4) are on both lists… what a pity…
I think, being almost sure as far as I could check by searching in the script’s output only the files being used twice (ore more) times in the timeline appear on both lists.
(I had cut some of the same footage clips to apply a different speed).
update
I found a clip in the playlist but NOT used in the timeline which is also on the delete list…
Anyway its a very valuable script, thanks a lot.
I’ve used the upper part to find the used files, moved them to another folder and could deleted the non used ones, changed the path in the .mlt file by replacement and its all fine.