History

option to copy files by masks. fixes issue #15

Serge Zirukin committed 15 years ago

Commit 55c65fd1 parent 24b9db51 file · +32 −3Browse files

Unified · Split

split2flac.sh+32−3
@@ -49,6 +49,8 @@ FORMAT="${0##*split2}" · 48 unmodified lines
4949 FORMAT="${FORMAT%.sh}"
5050 DIR="."
5151 OUTPATTERN="@artist/{@year - }@album/@track - @title.@ext"
52+COPYMASKS="Covers,covers,*.log,*.txt,*.jpg,*.cbr"
53+COPYFILES=1
5254
5355 # codecs default arguments
5456 ENCARGS_flac="-8"
@@ -66,7 +68,7 @@ unset PIC INPATH CUE CHARSET · 11 unmodified lines
6668 FORCE=0
6769
6870 # do not forget to update before commit
69−VERSION=95
71+VERSION=96
7072
7173 HELP="\${cG}split2flac version: ${VERSION}
7274 Splits one big \${cU}APE/FLAC/WV/WAV\$cZ\$cG audio image (or a collection) into \${cU}FLAC/M4A/MP3/OGG_VORBIS/WAV\$cZ\$cG tracks with tagging and renaming.
@@ -84,6 +86,8 @@ Usage: \${cZ}split2\${FORMAT}.sh [\${cU}OPTIONS\$cZ] \${cU}FILE\$cZ [\${cU}OPTIO · 11 unmodified lines
8486 \$cG-eh\$cZ - show help for current encoder and exit\$cZ
8587 \$cG-c \${cU}FILE\$cZ \$cR*\$cZ - use file as a cover image (does not work with \${cU}DIR\$cZ)
8688 \$cG-nc \${cR}*\$cZ - do not set any cover images
89+ \$cG-C \${cU}MASKS\$cZ \$cR*\$cZ - specify wildcards for files to copy over (current is \$cP'\${COPYMASKS}'\$cZ)
90+ \$cG-nC \${cR}*\$cZ - do not copy any files
8791 \$cG-cs \${cU}WxH\$cZ \$cR*\$cZ - set cover image size (current is \$cP\${PIC_SIZE}\$cZ)
8892 \$cG-d \$cR*\$cZ - create artist/album subdirs (default)
8993 \$cG-nd \$cR*\$cZ - do not create any subdirs
@@ -150,6 +154,8 @@ while [ "$1" ]; do · 60 unmodified lines
150154 -eh) ENCHELP=1;;
151155 -c) NOPIC=0; PIC=$2; shift;;
152156 -nc) NOPIC=1;;
157+ -C) COPYMASKS="$1"; COPYFILES=1; shift;;
158+ -nC) COPYFILES=0;;
153159 -cs) PIC_SIZE=$2; shift;;
154160 -d) NOSUBDIRS=0;;
155161 -nd) NOSUBDIRS=1;;
@@ -186,6 +192,8 @@ eval "export ENCARGS_${FORMAT}=\"${ENCARGS}\"" · 30 unmodified lines
186192 if [ ${SAVE} -eq 1 ]; then
187193 echo "DIR=\"${DIR}\"" > "${CONFIG}"
188194 echo "OUTPATTERN=\"${OUTPATTERN}\"" >> "${CONFIG}"
195+ echo "COPYMASKS=\"${COPYMASKS}\"" >> "${CONFIG}"
196+ echo "COPYFILES=${COPYFILES}" >> "${CONFIG}"
189197 echo "NOSUBDIRS=${NOSUBDIRS}" >> "${CONFIG}"
190198 echo "NOPIC=${NOPIC}" >> "${CONFIG}"
191199 echo "REMOVE=${REMOVE}" >> "${CONFIG}"
@@ -335,13 +343,13 @@ split_file () { · 143 unmodified lines
335343 fi
336344 fi
337345
346+ SDIR=$(dirname "${FILE}")
347+
338348 # search for a front cover image
339349 if [ ${NOPIC} -eq 1 ]; then
340350 unset PIC
341351 elif [ -z "${PIC}" ]; then
342352 # try common names
343− SDIR=$(dirname "${FILE}")
344−
345353 for i in cover.jpg front_cover.jpg folder.jpg; do
346354 if [ -r "${SDIR}/$i" ]; then
347355 PIC="${SDIR}/$i"
@@ -371,6 +379,11 @@ split_file () { · 23 unmodified lines
371379 || $msg "$msg_removal if user says 'y'$cZ\n"
372380 fi
373381
382+ # files to copy over
383+ if [ ${COPYFILES} -eq 1 -a "${COPYMASKS}" ]; then
384+ $msg "${cG}Copy over :$cZ ${COPYMASKS}\n"
385+ fi
386+
374387 # get common tags
375388 TAG_ARTIST=$(${GETTAG} %P "${CUE}" 2>/dev/null)
376389 TAG_ALBUM=$(${GETTAG} %T "${CUE}" 2>/dev/null)
@@ -595,6 +608,22 @@ split_file () { · 218 unmodified lines
595608 fi
596609 fi
597610
611+ # copy files
612+ if [ ${COPYFILES} -eq 1 -a "${COPYMASKS}" ]; then
613+ old=`pwd`
614+ cd "${SDIR}"
615+ $msg "\n${cG}Copying files:$cZ\n"
616+ eval "for i in {${COPYMASKS}}; do \
617+ test -r \"\$i\" && \
618+ echo \" +> \$i\" 2>/dev/null; done"
619+ if [ ${DRY} -ne 1 ]; then
620+ eval "for i in {${COPYMASKS}}; do \
621+ test -r \"\$i\" && \
622+ cp -r \"\$i\" \"\${OUT}/\"; done"
623+ fi
624+ cd "${old}"
625+ fi
626+
598627 rm -f "${TMPPIC}"
599628 rm -f "${TMPCUE}"
600629

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t