remove unnecessary comments

This commit is contained in:
2025-09-09 12:07:05 +02:00
parent 7cf22df07d
commit 28272bc5da
2 changed files with 1 additions and 20 deletions

View File

@@ -24,28 +24,20 @@ echo "Metadata title set for all MP4 files in directory"
```bash
#!/bin/bash
# Loop through directories one level deep
for DIR in */ ; do
# Ensure it's a directory
if [ -d "$DIR" ]; then
# Loop through mp4 files in this subdirectory
for FILE_PATH in "$DIR"*.mp4; do
# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
continue
fi
# Extract basename without the path and extension
BASE_NAME=$(basename "$FILE_PATH" .mp4)
# Define a temp file path
TEMP_FILE="${FILE_PATH%.*}_temp.mp4"
# Set the metadata title using ffmpeg and then replace the original file
ffmpeg -i "$FILE_PATH" -c copy -metadata title="$BASE_NAME" "$TEMP_FILE" && mv -f "$TEMP_FILE" "$FILE_PATH"
done
fi
done
echo "Metadata title set for all MP4 files in subdirectories."
```
```

View File

@@ -31,27 +31,16 @@ done
```bash
#!/bin/bash
# Loop through each subdirectory in the current directory
for dir in */; do
# Check if it's a directory
if [[ -d "$dir" ]]; then
# Find the first .mp4 file in the directory
mp4_file=$(find "$dir" -maxdepth 1 -type f -name '*.mp4' | head -n 1)
# If a .mp4 file is found
if [[ -n "$mp4_file" ]]; then
# Get the file's basename without path and extension
mp4_base_name="$(basename "${mp4_file}" .mp4)"
# Trim the trailing slash from the directory name
trimmed_dir_name="${dir%/}"
# New directory name will be the name of the .mp4 file
new_dir_name="${mp4_base_name}"
# Rename the directory, only if new directory name is different than the original
if [[ "$trimmed_dir_name" != "$new_dir_name" ]]; then
# Check if target directory name already exists
if [[ ! -d "$new_dir_name" ]]; then
mv -n "$dir" "$new_dir_name"
echo "Renamed directory '$dir' to '$new_dir_name'"