Skip to content

Instantly share code, notes, and snippets.

@vadimshvetsov
Last active January 27, 2017 12:36
Show Gist options
  • Save vadimshvetsov/4239abe765613db8ec7e109c6eb0f6ba to your computer and use it in GitHub Desktop.
Save vadimshvetsov/4239abe765613db8ec7e109c6eb0f6ba to your computer and use it in GitHub Desktop.
Script for copy datetime from original MOV/MP4 file to compressed.
#!/bin/bash
# Get all files with uppercase MP4 and MOV
files='*.MP4 *.MOV';
# Go through files
for f in $files;
do
# Create a regexp for find compressed file
regexp=$(echo $f | sed -e "s/\(.*\)\(\.\)\(...\)/\1\*.\L\3/"| tr -d '\n');
# Find compressed file
compressed=$(echo $regexp);
# If file exists
if [ -f "$compressed" ]
then
echo "File $f is updated"
# Modify with original date & time
touch -r $f $compressed
# Remove original file and rename compressed
mv $compressed $f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment