Cybrkyd's git repositories

scripts • commit: 02c58e7

commit 02c58e79586438d7bd2f4453ab9c666ee8f5633a9e7d0f5b45c80286641aee26
author cybrkyd <noreply@cybrkyd.com> 2026-01-16 10:08:08 +0000
committer cybrkyd <noreply@cybrkyd.com> 2026-01-16 10:08:08 +0000

Commit Message

Initial commit

📊 Diffstat

README.md 10
movie.sh 38
redistribute-files.sh 41
xsct.sh 8
4 files changed, 97 insertions(+), 0 deletions(-)

Diff

commit 02c58e79586438d7bd2f4453ab9c666ee8f5633a9e7d0f5b45c80286641aee26
Author: cybrkyd <noreply@cybrkyd.com>
Date: Fri Jan 16 10:08:08 2026 +0000
Initial commit
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9042980
--- /dev/null
+++ b/README.md
@@ -0,0 +1,10 @@
+ # Scripts
+
+ Collection of shell scripts.
+
+ |Script |Description |
+ |----------------|----------------|
+ |movie.sh |Get the filename, file size and resolution of video files in a directory. |
+ |redistribute-files.sh |Redistribute files amongst sub-folders. |
+ |xsct.sh |xsct script to set colour temperature of screen. |
+
diff --git a/movie.sh b/movie.sh
new file mode 100644
index 0000000..4ae48a0
--- /dev/null
+++ b/movie.sh
@@ -0,0 +1,38 @@
+ #!/bin/bash
+
+ # Get the filename, file size and resolution of video files
+ # in a directory.
+
+ MOVIE_DIR="/media/movies"
+ OUTPUT_FILE="video_info.csv"
+
+ # Write CSV header
+ echo "Filename,Size,Resolution" > "$OUTPUT_FILE"
+
+ # Recursively find all MKV, MP4, and AVI files
+ find "$MOVIE_DIR" -type f \( -iname "*.mkv" -o -iname "*.mp4" -o -iname "*.avi" \) | while read -r FILE
+ do
+
+ FILE_SIZE_BYTES=$(stat --printf="%s" "$FILE")
+
+ # Convert to human-readable MB or GB with 1 decimal
+ if [ "$FILE_SIZE_BYTES" -ge 1073741824 ]; then
+ SIZE_HUMAN=$(awk "BEGIN {printf \"%.1fGB\", $FILE_SIZE_BYTES/1073741824}")
+ else
+ SIZE_HUMAN=$(awk "BEGIN {printf \"%.1fMB\", $FILE_SIZE_BYTES/1048576}")
+ fi
+
+ # Get resolution (width x height)
+ RESOLUTION=$(ffprobe -v error -select_streams v:0 \
+ -show_entries stream=width,height \
+ -of default=noprint_wrappers=1:nokey=1 "$FILE" | paste -sdx -)
+
+ # Escape filename for CSV
+ FILE_NAME=$(basename "$FILE" | sed 's/"/""/g')
+
+ # Write to CSV
+ echo "\"$FILE_NAME\",\"$SIZE_HUMAN\",\"$RESOLUTION\"" >> "$OUTPUT_FILE"
+ done
+
+ echo "Video info written to $OUTPUT_FILE"
+
diff --git a/redistribute-files.sh b/redistribute-files.sh
new file mode 100644
index 0000000..f60cbb6
--- /dev/null
+++ b/redistribute-files.sh
@@ -0,0 +1,41 @@
+ #!/bin/bash
+
+ # Parent directory containing sub-folders
+ parent_dir="images"
+
+ # Maximum number of files allowed in each sub-folder
+ max_files=1000
+
+ # Get a list of all sub-folders in the parent directory
+ subfolders=("$parent_dir"/*/)
+
+ # Create a temporary folder to store excess files
+ temp_folder="$parent_dir/temp_folder"
+ mkdir -p "$temp_folder"
+
+ # Collect excess files into temp
+ for folder in "${subfolders[@]}"; do
+ file_count=$(find "$folder" -type f | wc -l)
+ if [ "$file_count" -gt "$max_files" ]; then
+ # Move excess files to temp
+ excess_files=$((file_count - max_files))
+ find "$folder" -type f | head -n "$excess_files" | xargs -I {} mv {} "$temp_folder/"
+ fi
+ done
+
+ # Redistribute files from temp to sub-folders
+ while IFS= read -r file; do
+ for folder in "${subfolders[@]}"; do
+ file_count=$(find "$folder" -type f | wc -l)
+ if [ "$file_count" -lt "$max_files" ]; then
+ mv "$file" "$folder"
+ break
+ fi
+ done
+ done < <(find "$temp_folder" -type f)
+
+ # Clean up
+ rmdir "$temp_folder"
+
+ echo "File redistribution complete!"
+
diff --git a/xsct.sh b/xsct.sh
new file mode 100644
index 0000000..b66bf16
--- /dev/null
+++ b/xsct.sh
@@ -0,0 +1,8 @@
+ #!/bin/sh
+
+ # Run this with CRON. For example, near sunset:
+ # 0 16 * * * /home/user/shell-scripts/xsct.sh
+
+ export DISPLAY=:0.0
+ xsct 4600 &
+