Skip to content

Instantly share code, notes, and snippets.

@ralphcrisostomo
Created September 10, 2016 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphcrisostomo/128ce79d2545813675d299454e344026 to your computer and use it in GitHub Desktop.
Save ralphcrisostomo/128ce79d2545813675d299454e344026 to your computer and use it in GitHub Desktop.
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