63 lines
1.5 KiB
Bash
Executable File
63 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
SRCFILE="$1"
|
|
TMPFILE="$2"
|
|
LOGFILE="$3"
|
|
echo $(date) $TMPFILE "created for \"$SRCFILE\"" >> $LOGFILE
|
|
if [[ $(ffp_duration $TMPFILE) == $(ffp_duration "$SRCFILE") ]]
|
|
then
|
|
NEWFILE="$(cut_ext "$SRCFILE").mp4"
|
|
mv "$SRCFILE" "$SRCFILE.bak"
|
|
mv "$TMPFILE" "$NEWFILE"
|
|
echo $(date) "$(pwd)/$\" done!" >> $LOGFILE
|
|
else
|
|
keep_temp "$SRCFILE" $TMPFILE
|
|
echo "SOMETHING WRONG!!"
|
|
echo $(date) "\"$(pwd)/$SRCFILE\" NOT FINISHED!" >> $LOGFILE
|
|
fi
|
|
#!/bin/bash
|
|
|
|
SRCFILE="$1"
|
|
TMPFILE="$2"
|
|
LOGFILE="$3"
|
|
|
|
# Log the creation of the temporary file
|
|
echo "$(date) $TMPFILE created for \"$SRCFILE\"" >> "$LOGFILE"
|
|
|
|
# Function to check duration
|
|
ffp_duration() {
|
|
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"
|
|
}
|
|
|
|
# Function to remove the file extension
|
|
cut_ext() {
|
|
echo "${1%.*}"
|
|
}
|
|
|
|
# Check if the durations of the source and temporary files match
|
|
if [[ $(ffp_duration "$TMPFILE") == $(ffp_duration "$SRCFILE") ]]; then
|
|
NEWFILE="$(cut_ext "$SRCFILE").mp4"
|
|
|
|
# Backup the original file
|
|
mv "$SRCFILE" "$SRCFILE.bak"
|
|
|
|
# Replace the original file with the new file
|
|
mv "$TMPFILE" "$NEWFILE"
|
|
|
|
# Log the successful operation
|
|
echo "$(date) $(pwd)/$SRCFILE done!" >> "$LOGFILE"
|
|
else
|
|
# Function to keep the temporary file
|
|
keep_temp() {
|
|
local src="$1"
|
|
local tmp="$2"
|
|
mv "$tmp" "${src}_tmp"
|
|
}
|
|
|
|
keep_temp "$SRCFILE" "$TMPFILE"
|
|
|
|
# Log the failure
|
|
echo "SOMETHING WRONG!!"
|
|
echo "$(date) $(pwd)/$SRCFILE NOT FINISHED!" >> "$LOGFILE"
|
|
fi
|
|
|