From 0da03b6b03c5ac3b3e711c4d5cffcca46faf6343 Mon Sep 17 00:00:00 2001 From: Kaan Genc Date: Sat, 19 Mar 2022 01:15:31 -0400 Subject: [PATCH] batch processong on the CLI --- content/mass-batch-processing-on-the-CLI.md | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 content/mass-batch-processing-on-the-CLI.md diff --git a/content/mass-batch-processing-on-the-CLI.md b/content/mass-batch-processing-on-the-CLI.md new file mode 100644 index 0000000..427a1a0 --- /dev/null +++ b/content/mass-batch-processing-on-the-CLI.md @@ -0,0 +1,60 @@ +--- +title: Mass batch processing on the CLI +date: 2022-03-19 +--- + +> This post is day 4 of me taking part in the +> [#100DaysToOffload](https://100daystooffload.com/) challenge. + +Some time ago, I needed to process a lot of video files with vlc. This is +usually pretty easy to do, `for file in *.mp4 ; do ffmpeg ... ; done` is about +all you need in most cases. However, sometimes the files you are trying to +process are in different folders. And sometimes you want to process some files +in a folder but not others. That's the exact situation I was in, and I was +wondering if I needed to find some graphical application with batch processing +capabilities so I can queue up all the processing I need. + +After a bit of thinking though, I realized I could do this very easily with a +simple shell script! That shell script lives in my [mark-list](https://github.com/SeriousBug/mark-list) +repository. + +The idea is simple, you use the command to mark a bunch of files. Every file you +mark is saved into a file for later use. + +```bash +$ mark-list my-video.mp4 # Choose a file +Marked 1 file. +$ mark-list *.webm # Choose many files +Marked 3 files. +$ cd Downloads +$ mark-list last.mpg # You can go to other directories and keep marking +``` + +You can mark a single file, or a bunch of files, or even navigate to other +directories and mark files there. + +Once you are done marking, you can recall what you marked with the same tool: + +```bash +$ mark-list --list +/home/kaan/my-video.mp4 +/home/kaan/part-1.webm +/home/kaan/part-2.webm +/home/kaan/part-3.webm +/home/kaan/Downloads/last.mpg +``` + +You can then use this in the command line. For example, I was trying to convert everything to `mkv` files. + +```bash +for file in `mark-list --list` ; do ffmpeg -i "${file}" "${file}.mkv" ; done +``` + +It works! After you are done with it, you then need to clear out your marks: + +``` +mark-list --clear +``` + +Hopefully this will be useful for someone else as well. It does make it a lot +easier to just queue up a lot of videos, and convert all of them overnight.