NixOS/workstation/scripts/split-dir.sh

29 lines
612 B
Bash
Executable File

#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash fd
before_count=$(fd -tf | wc -l)
i=0
for file in $(fd -d1 -tf -E '*.mp4'); do
dir_name=$(basename "$(pwd)")_$(printf %03d $((i / $1 + 1)))
mkdir -p "$dir_name"
mv -i "$file" "$(realpath "$dir_name")"/
i=$((i + 1))
done
for file in $(fd -d1 -tf -e mp4); do
mkdir -p videos
mv -i "$file" "$(realpath videos)"/
done
after_count=$(fd -tf | wc -l)
if [[ "$before_count" == "$after_count" ]]; then
echo "No file count differences"
else
echo "Before count: $before_count"
echo "After count: $after_count"
fi
sleep 10
exit