Allow passing filename with each flac file to process on a new line
This commit is contained in:
@@ -1,25 +1,48 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# script to fix where flac tags are set correctly but navidrome still sees them as having [Unknown album] and [Unknown artist]
|
# script to fix where flac tags are set correctly but navidrome still sees them as having [Unknown album] and [Unknown artist]
|
||||||
# usage: fix_unknown_album_and_artist_flac_file.sh FILENAME [LOCATION]
|
# usage: fix_unknown_album_and_artist_flac_file.sh FILENAME [LOCATION] [-l]
|
||||||
# parameters:
|
# parameters:
|
||||||
# FILENAME: file to fix
|
# FILENAME: file to fix. Can be a relative or absolute path
|
||||||
# LOCATION: optional, location of the file, if the script is run from a different directory than where the file to fix is.
|
# LOCATION: optional, location of the file, if the script is run from a different directory than where the file to fix is.
|
||||||
|
# -l LISTFILE: optional, location of file containing multiple files to fix, each starting with a new line.
|
||||||
|
# This is the same as running the script for each single file in the list
|
||||||
|
|
||||||
|
|
||||||
|
function fix_flac_file()
|
||||||
|
{
|
||||||
|
echo "Fixing flac file $1"
|
||||||
|
|
||||||
|
echo "running command ffmpeg -i $1 -c:a flac -map_metadata 0 fixed.flac"
|
||||||
|
|
||||||
|
ffmpeg -i "$1" -c:a flac -map_metadata 0 "fixed.flac"
|
||||||
|
|
||||||
|
echo "moving fixed.flac to $1"
|
||||||
|
mv "fixed.flac" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z "$2" ]
|
if [ -z "$2" ]
|
||||||
then
|
then
|
||||||
echo "staying in current directory"
|
echo "staying in current directory"
|
||||||
else
|
else
|
||||||
|
if [ "$2" = "-l" ]
|
||||||
|
then
|
||||||
|
if [ -z "$3" ]
|
||||||
|
then
|
||||||
|
echo "Please provide the location of the file with multiple entries to fix"
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
echo "Looping through $3"
|
||||||
|
while read flacfile; do
|
||||||
|
echo "Processing line $flacfile"
|
||||||
|
fix_flac_file "$flacfile"
|
||||||
|
done < "$3"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
else
|
||||||
echo "moving to $2"
|
echo "moving to $2"
|
||||||
cd "$2"
|
cd "$2"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Fixing flac file $1"
|
fix_flac_file $1
|
||||||
|
|
||||||
echo "running command ffmpeg -i $1 -c:a flac -map_metadata 0 fixed.flac"
|
|
||||||
|
|
||||||
ffmpeg -i "$1" -c:a flac -map_metadata 0 "fixed.flac"
|
|
||||||
|
|
||||||
echo "moving fixed.flac to $1"
|
|
||||||
mv "fixed.flac" "$1"
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user