Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 35 additions and 26 deletions.
  1. +35 −26 flacconvert.sh
View
61 flacconvert.sh
@@ -275,19 +275,30 @@ function convert_path
local backwards="$5" # whether file is a destination file,
# if so, convert it to the source file
- if [ ! "$backwards" = "1" ]
+ if [ "$backwards" = "1" ]
+ then
+ local tmp=$base
+ base=$dest
+ dest=$tmp
+ fi
+
+ # files right under dest shall not have convpath
+ if [ -f "$file" -a "${file%/*}/" = "$base" ]
+ then
+ convpath=
+ fi
+
+ file=${file#"$base"}
+ file_substring=${file%%/*}
+ local replacement=$dest$file_substring
+ if [ "$backwards" = "1" ]
then
- file=${file#"$base"}
- file_substring=${file%%/*}
- local replacement=$dest$file_substring$convpath
- file=${file/#"$file_substring"/"$replacement"}
- else
- file=${file#"$dest"}
- file_substring=${file%%/*}
- local replacement=$base$file_substring
replacement=${replacement%"$convpath"}
- file=${file/#"$file_substring"/"$replacement"}
+ else
+ replacement=$replacement$convpath
fi
+ file=${file/#"$file_substring"/"$replacement"}
+
echo "$file"
}
@@ -391,7 +402,7 @@ function remove_obsolete_files
local dest="$1" # destination folder with trailing slash
local src="$2" # flac folder with trailing slash
local convpath="$3" # suffix
- local ext="$4" # which extension have trancscoded files
+ local ext="$4" # extension of trancscoded files
ext="$(sed "s/^m4aNero$/m4a/" <<< "$ext")"
@@ -408,26 +419,24 @@ function remove_obsolete_files
fi
done
- # remove copied and linked files
+ # remove copied, linked and transcoded files
find_exts "$dest" ${copy_exts[@]} ${hard_link_exts[@]} \
- ${sym_link_exts[@]} | while read destfile
+ ${sym_link_exts[@]} "$ext" | while read destfile
do
srcfile=$(convert_path "$src" "$dest" "$destfile" "$convpath" 1)
if [ ! -e "$srcfile" ]
then
- rm -f "$destfile"
- fi
- done
-
- # remove transcoded files
- find "$dest" -type f -iname "*.$ext" | while read destfile
- do
- file=$(convert_path "$src" "$dest" "$destfile" "$convpath" 1)
- srcfile=${file%.*}.flac
- srcfile2=${file%.*}.FLAC
- if [ ! -e "$srcfile" -a ! -e "$srcfile2" ]
- then
- rm -f "$destfile"
+ if [ "${destfile##*.}" = "$ext" ]
+ then
+ srcfile1=${srcfile%.*}.flac
+ srcfile2=${srcfile%.*}.FLAC
+ if [ ! -e "$srcfile1" -a ! -e "$srcfile2" ]
+ then
+ rm -f "$destfile"
+ fi
+ else
+ rm -f "$destfile"
+ fi
fi
done
}

No commit comments for this range

Something went wrong with that request. Please try again.