Skip to content

Run the exact same batch cut or operation on multiple files #868

@mifi

Description

@mifi

NOTE: This is different from #89, because that is just a workflow improvement.

This feature is about running the exact same operation (or cut) on multiple files, e.g. you have a folder with a number of files, and you want to do the exact same thing with all files.

Such a feature could be implemented by having an extra "Tools" menu or an option in the Export dialog where the user selects additional files to run the same edit on. Or the operation could be done on all files the currently loaded batch list.

Note that I haven't prioritised this very highly, because there are so many different wishes and these kinds of operations can often be easily automated by bash scripting using ffmpeg directly (even with the help of AI, see workaround below)

Batch same cut on multiple files

This might done on be all files in the "batch list".

Other batch operations

Grouped batching

Workaround: bash script

See also Batch processing article

A simple workaround is to write a bash script and use ffmpeg directly. For example to cut multiple files exactly the same, create a file batch.sh with this content:

# example: cut away 30 sec from start of all files, and include everything until 60 sec
# adjust the following values:
TIME_TO_CUT_FROM=30
TIME_TO_CUT_TO=60
FOLDER_PATH=/path/to/files/*.mp4

for FILE in "$FOLDER_PATH"
do
  # This ffmpeg command can be replaced with whichever operation you'd like to run on all the files.
  # It could also be an ffmpeg command copy-pasted from LosslessCut (and adjusted)
  ffmpeg -ss "$TIME_TO_CUT_FROM" -i "$FILE" -t "$TIME_TO_CUT_TO" -c copy "$FILE-cut.mp4"
done

Note that the example script above is for UNIX based operating systems like MacOS/Linux. Windows users: If you need to do this on Windows, maybe you can ask ChatGPT something like: "Convert this command from bash to Windows Batch" and paste the above command. Or you can use WSL2.

Tip: First run your desired operation (e.g. a cut) in LosslessCut on your first file in your batch list. Then open then "Last ffmpeg commands" menu, and look at the last ffmpeg command that was run. Then copy this and paste it into the above script. You then need to insert variables like $TIME_TO_CUT_FROM, $TIME_TO_CUT_TO and $FILE into the command you copy pasted.

Bonus: ChatGPT / AI

I wish more people were aware of this, but large language models like ChatGPT can be incredibly useful for helping non-programmers with simple programming tasks.

Basically you just need to ask the AI to write a script for you to do whatever you need. If it doesn't work, you can continue the conversation to try to get it corrected. And it's free!

Here are a few examples:

Batch split files into equal length segments

write a bash script that takes a folder of mp4 files, then for each file, split it into an (unknown) number of files, each file of an equal length of 299 seconds.

This gave me the following script: #2011 (comment)

Batch rotate all files to 90 degrees

write a bash script that takes a folder of mp4 files, then for each file, losslessly change the rotation to 90 degrees and output to the same folder.

You know the drill now...

Then once you have the script, you can ask ChatGPT "how do I run this?"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions