Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copy and rename videos from a directory
# #!/bin/bash
#
# Copy and Rename Videos
# Created by : Ralph Crisostomo - 2016/09/10
#
# ./copy_rename_videos.sh /source/dir /destination/dir
#
SOURCE_DIR="$1"
VIDEO_DIR="$2"
COUNTER=0000
find -E "$SOURCE_DIR" -iregex '.*\.(mts|mov|mp4|mkv)' | while read -r LINE
do
COUNTER=$[$COUNTER +1]
EXT="${LINE##*.}"
EXT=$(echo $EXT | tr "[:upper:]" "[:lower:]")
NEW_FILE=$(printf "%05d.$EXT\n" $COUNTER)
cp -v "$LINE" "$VIDEO_DIR/$NEW_FILE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.