From 9c9bcab59f7516f25501c0c6fc97628974bb5302 Mon Sep 17 00:00:00 2001 From: Haffel Date: Thu, 6 Nov 2025 13:11:42 +0100 Subject: [PATCH] add script to find short videos --- .obsidian/workspace.json | 70 ++++++++++++++++++++++++++++++++++++---- find-short-videos.md | 29 +++++++++++++++++ 2 files changed, 93 insertions(+), 6 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 1693631..f89cd09 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -38,6 +38,64 @@ "icon": "lucide-file", "title": "metadata-stuff" } + }, + { + "id": "1edaeb936a995d2c", + "type": "leaf", + "pinned": true, + "state": { + "type": "markdown", + "state": { + "file": "move-file-into-dir-with-same-name.md", + "mode": "source", + "source": false + }, + "pinned": true, + "icon": "lucide-file", + "title": "move-file-into-dir-with-same-name" + } + }, + { + "id": "50fc2c454baeec28", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "bring-files-up-one-dir.md", + "mode": "source", + "source": false + }, + "icon": "lucide-file", + "title": "bring-files-up-one-dir" + } + }, + { + "id": "4c3684fe958a6ed9", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "bulk-move.md", + "mode": "source", + "source": false + }, + "icon": "lucide-file", + "title": "bulk-move" + } + }, + { + "id": "b527262a94efda07", + "type": "leaf", + "state": { + "type": "markdown", + "state": { + "file": "move-file-into-dir-with-same-name.md", + "mode": "source", + "source": false + }, + "icon": "lucide-file", + "title": "move-file-into-dir-with-same-name" + } } ], "currentTab": 1 @@ -187,12 +245,14 @@ }, "active": "aad5fb65253dfe6f", "lastOpenFiles": [ - "rename-nested-file-to-parent.md", - "metadata-stuff.md", "move-file-into-dir-with-same-name.md", - "ffmpeg.md", - "find-short-videos.md", + "metadata-stuff.md", "bulk-move.md", + "find-short-videos.md", + "rename-nested-file-to-parent.md", + "bring-files-up-one-dir.md", + "remove-timestamps.md", + "ffmpeg.md", "regex-stuff.md", "add-prefix-to-file.md", "usr-local-bin/setartist", @@ -201,7 +261,6 @@ "usr-local-bin/cutto", "usr-local-bin/cutfrom", "usr-local-bin", - "remove-timestamps.md", "remove-n-chars-from-name.md", "remove-n-chars-from-name_handle-duplicates.md", "recursively-extract-artist-from-filename.md", @@ -210,7 +269,6 @@ "move-files-to-year-and-month-dirs.md", "move-file-in-dir-with-same-name.md", "filename-as-metadata-title.md", - "bring-files-up-one-dir.md", "auto-fill-missing-artist-tags.md" ] } \ No newline at end of file diff --git a/find-short-videos.md b/find-short-videos.md index fde4f7f..8ee9615 100644 --- a/find-short-videos.md +++ b/find-short-videos.md @@ -28,3 +28,32 @@ done echo "Operation complete. The list of parent directories has been saved to $OUTPUT_FILE." ``` + +```bash +#!/bin/bash + +DURATION_THRESHOLD_SECONDS=180 +IGNORED_FOLDERS=("backdrops") +OUTPUT_FILE="short_video_dirs.txt" + +> "$OUTPUT_FILE" + +find . -type f -name "*.mp4" | while read -r file; do + parent_dir=$(dirname "$file") + + for ignored_folder in "${IGNORED_FOLDERS[@]}"; do + if [[ "$parent_dir" == *"$ignored_folder"* ]]; then + continue 2 + fi + done + + length=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file") + length=$(printf "%.0f\n" "$length") + + if [ "$length" -lt "$DURATION_THRESHOLD_SECONDS" ]; then + echo "$file" >> "$OUTPUT_FILE" + fi +done + +echo "Operation complete. The list of parent directories has been saved to $OUTPUT_FILE." +```