History

restyle

Serge Zirukin committed 16 years ago

Commit 9beb96c1 parent e771c7b1 file · +41 −82Browse files

Unified · Split

split2flac.sh+41−82
@@ -78,8 +78,7 @@ every time, only a filename. · 77 unmodified lines
7878 Script will try to find CUE sheet if it wasn't specified."
7979
8080 # parse arguments
81−while [ "$1" ]
82−do
81+while [ "$1" ]; do
8382 case "$1" in
8483 -o) DIR=$2; shift;;
8584 -cue) CUE=$2; shift;;
@@ -99,13 +98,11 @@ do · 13 unmodified lines
9998 -h) eval "echo \"${HELP}\""; exit 0;;
10099 -H) echo "${README}"; exit 0;;
101100 *)
102− if [ -r "${FILE}" ]
103− then
101+ if [ -r "${FILE}" ]; then
104102 echo "Unknown option $1"
105103 eval "echo \"${HELP}\""
106104 exit 1
107− elif [ ! -r "$1" ]
108− then
105+ elif [ ! -r "$1" ]; then
109106 echo "Unable to read $1"
110107 exit 1
111108 else
@@ -120,30 +117,24 @@ VORBISCOMMENT="vorbiscomment -R -a" · 8 unmodified lines
120117 ID3TAG="id3tag -2"
121118
122119 # search for a cue sheet if not specified
123−if [ -z "${CUE}" ]
124−then
120+if [ -z "${CUE}" ]; then
125121 CUE="${FILE}.cue"
126− if [ ! -r "${CUE}" ]
127− then
122+ if [ ! -r "${CUE}" ]; then
128123 CUE=$(echo ${FILE} | sed 's/[^\.]*$//')cue
129− if [ ! -r "${CUE}" ]
130− then
124+ if [ ! -r "${CUE}" ]; then
131125 # try to extract internal one
132126 # MacOSX sed doesn't have 'I' (case insensitive) flag!
133127 CUESHEET=$(${METAFLAC} --show-tag=CUESHEET "${FILE}" 2>/dev/null | sed 's/[Cc][Uu][Ee][Ss][Hh][Ee][Ee][Tt]=//')
134128
135− if [ -z "${CUESHEET}" ]
136− then
129+ if [ -z "${CUESHEET}" ]; then
137130 CUESHEET=$(wvunpack -q -c "${FILE}" 2>/dev/null)
138131 fi
139132
140− if [ "${CUESHEET}" ]
141− then
133+ if [ "${CUESHEET}" ]; then
142134 CUE="${TMPCUE}"
143135 echo "${CUESHEET}" > "${CUE}"
144136
145− if [ $? -ne 0 ]
146− then
137+ if [ $? -ne 0 ]; then
147138 echo "Unable to save internal cue sheet"
148139 exit 1
149140 fi
@@ -159,29 +150,23 @@ echo "Input file :" ${FILE:?"No input filename given. Use -h for help."} · 9 unmodified lines
159150 echo "Cue sheet :" ${CUE:?"No cue sheet"}
160151
161152 # search for a front cover image
162−if [ ${NOPIC} -eq 1 ]
163−then
153+if [ ${NOPIC} -eq 1 ]; then
164154 unset PIC
165−elif [ -z "${PIC}" ]
166−then
155+elif [ -z "${PIC}" ]; then
167156 # try common names
168157 SDIR=$(dirname "${FILE}")
169158
170− for i in cover.jpg front_cover.jpg folder.jpg
171− do
172− if [ -r "${SDIR}/$i" ]
173− then
159+ for i in cover.jpg front_cover.jpg folder.jpg; do
160+ if [ -r "${SDIR}/$i" ]; then
174161 PIC="${SDIR}/$i"
175162 break
176163 fi
177164 done
178165
179166 # try to extract internal one
180− if [ -z "${PIC}" ]
181− then
167+ if [ -z "${PIC}" ]; then
182168 ${METAFLAC} --export-picture-to="${TMPPIC}" "${FILE}" 2>/dev/null
183− if [ $? -ne 0 ]
184− then
169+ if [ $? -ne 0 ]; then
185170 echo "Unable to export internal front cover image"
186171 unset PIC
187172 else
@@ -194,11 +179,9 @@ echo "Cover image :" ${PIC:-"not set"} · 6 unmodified lines
194179 echo "Output dir :" ${DIR:?"Output directory wasn't set"}
195180
196181 # file removal warning
197−if [ ${REMOVE} -eq 1 ]
198−then
182+if [ ${REMOVE} -eq 1 ]; then
199183 echo -n "Also remove original"
200− if [ ${FORCE} -eq 1 ]
201− then
184+ if [ ${FORCE} -eq 1 ]; then
202185 echo
203186 else
204187 echo " if user says 'y'"
@@ -206,8 +189,7 @@ then · 1 unmodified line
206189 fi
207190
208191 # save configuration if needed
209−if [ ${SAVE} -eq 1 ]
210−then
192+if [ ${SAVE} -eq 1 ]; then
211193 echo "DIR=\"${DIR}\"" > "${CONFIG}"
212194 echo "NOSUBDIRS=${NOSUBDIRS}" >> "${CONFIG}"
213195 echo "NORENAME=${NORENAME}" >> "${CONFIG}"
@@ -230,10 +212,8 @@ YEAR=$(echo ${YEAR} | tr -d -C '[:digit:]') · 16 unmodified lines
230212
231213 unset TAG_DATE
232214
233−if [ -n "${YEAR}" ]
234−then
235− if [ ${YEAR} -ne 0 ]
236− then
215+if [ -n "${YEAR}" ]; then
216+ if [ ${YEAR} -ne 0 ]; then
237217 TAG_DATE="${YEAR}"
238218 fi
239219 fi
@@ -241,8 +221,7 @@ fi · 1 unmodified line
241221 echo
242222 echo "Artist : ${TAG_ARTIST}"
243223 echo "Album : ${TAG_ALBUM}"
244−if [ -n "${TAG_DATE}" ]
245−then
224+if [ -n "${TAG_DATE}" ]; then
246225 echo "Year : ${TAG_DATE}"
247226 fi
248227 echo "Tracks : ${TRACKS_NUM}"
@@ -251,13 +230,11 @@ echo · 2 unmodified lines
251230 # prepare output directory
252231 OUT="${DIR}"
253232
254−if [ ${NOSUBDIRS} -ne 1 ]
255−then
233+if [ ${NOSUBDIRS} -ne 1 ]; then
256234 DIR_ARTIST=$(echo ${TAG_ARTIST} | ${VALIDATE})
257235 DIR_ALBUM=$(echo ${TAG_ALBUM} | ${VALIDATE})
258236
259− if [ "${TAG_DATE}" ]
260− then
237+ if [ "${TAG_DATE}" ]; then
261238 DIR_ALBUM="${TAG_DATE} - ${DIR_ALBUM}"
262239 fi
263240
@@ -266,13 +243,11 @@ fi · 2 unmodified lines
266243
267244 echo "Saving tracks to \"${OUT}\""
268245
269−if [ ${DRY} -ne 1 ]
270−then
246+if [ ${DRY} -ne 1 ]; then
271247 # create output dir
272248 mkdir -p "${OUT}"
273249
274− if [ $? -ne 0 ]
275− then
250+ if [ $? -ne 0 ]; then
276251 echo "Failed to create output directory"
277252 exit 1
278253 fi
@@ -287,18 +262,15 @@ then · 8 unmodified lines
287262 # split to tracks
288263 cuebreakpoints "${CUE}" | \
289264 shnsplit -O never -o "${ENC}" -d "${OUT}" -t "%n" "${FILE}"
290− if [ $? -ne 0 ]
291− then
265+ if [ $? -ne 0 ]; then
292266 echo "Failed to split"
293267 exit 1
294268 fi
295269
296270 # prepare cover image
297− if [ "${PIC}" ]
298− then
271+ if [ "${PIC}" ]; then
299272 convert "${PIC}" -resize "${PIC_SIZE}" "${TMPPIC}"
300− if [ $? -eq 0 ]
301− then
273+ if [ $? -eq 0 ]; then
302274 PIC="${TMPPIC}"
303275 else
304276 echo "Failed to convert cover image"
@@ -312,8 +284,7 @@ echo · 7 unmodified lines
312284 echo "Setting tags"
313285
314286 i=1
315−while [ $i -le ${TRACKS_NUM} ]
316−do
287+while [ $i -le ${TRACKS_NUM} ]; do
317288 TAG_TITLE=$(cueprint -n $i -t %t "${CUE}")
318289 f="${OUT}/$(printf %02i $i).${FORMAT}"
319290 FILE_TRACK=$(basename "$f" .${FORMAT})
@@ -321,14 +292,11 @@ do · 1 unmodified line
321292
322293 echo "$i: ${TAG_TITLE}"
323294
324− if [ ${NORENAME} -ne 1 ]
325− then
295+ if [ ${NORENAME} -ne 1 ]; then
326296 FINAL="${OUT}/${FILE_TRACK} - ${FILE_TITLE}.${FORMAT}"
327− if [ ${DRY} -ne 1 ]
328− then
297+ if [ ${DRY} -ne 1 ]; then
329298 mv "$f" "${FINAL}"
330− if [ $? -ne 0 ]
331− then
299+ if [ $? -ne 0 ]; then
332300 echo "Failed to rename track file"
333301 exit 1
334302 fi
@@ -337,8 +305,7 @@ do · 2 unmodified lines
337305 FINAL="$f"
338306 fi
339307
340− if [ ${DRY} -ne 1 ]
341− then
308+ if [ ${DRY} -ne 1 ]; then
342309 case ${FORMAT} in
343310 flac)
344311 ${METAFLAC} --remove-all-tags \
@@ -349,14 +316,12 @@ do · 4 unmodified lines
349316 "${FINAL}" >/dev/null
350317 RES=$?
351318
352− if [ -n "${TAG_DATE}" ]
353− then
319+ if [ -n "${TAG_DATE}" ]; then
354320 ${METAFLAC} --set-tag="DATE=${TAG_DATE}" "${FINAL}" >/dev/null
355321 RES=$((${RES} + $?))
356322 fi
357323
358− if [ -n "${PIC}" ]
359− then
324+ if [ -n "${PIC}" ]; then
360325 ${METAFLAC} --import-picture-from="${PIC}" "${FINAL}" >/dev/null
361326 RES=$((${RES} + $?))
362327 fi
@@ -371,8 +336,7 @@ do · 8 unmodified lines
371336 "${FINAL}" >/dev/null
372337 RES=$?
373338
374− if [ -n "${TAG_DATE}" ]
375− then
339+ if [ -n "${TAG_DATE}" ]; then
376340 ${ID3TAG} -y"${TAG_DATE}" "${FINAL}" >/dev/null
377341 RES=$((${RES} + $?))
378342 fi
@@ -386,8 +350,7 @@ do · 7 unmodified lines
386350 -t "TRACKNUMBER=$i" >/dev/null
387351 RES=$?
388352
389− if [ -n "${TAG_DATE}" ]
390− then
353+ if [ -n "${TAG_DATE}" ]; then
391354 ${VORBISCOMMENT} "${FINAL}" -t "DATE=${TAG_DATE}" >/dev/null
392355 RES=$((${RES} + $?))
393356 fi
@@ -395,8 +358,7 @@ do · 1 unmodified line
395358 *) echo "Unknown output format ${FORMAT}"; exit 1;;
396359 esac
397360
398− if [ ${RES} -ne 0 ]
399− then
361+ if [ ${RES} -ne 0 ]; then
400362 echo "Failed to set tags for track"
401363 exit 1
402364 fi
@@ -410,18 +372,15 @@ done · 7 unmodified lines
410372 rm -f "${TMPPIC}"
411373 rm -f "${TMPCUE}"
412374
413−if [ ${DRY} -ne 1 -a ${REMOVE} -eq 1 ]
414−then
375+if [ ${DRY} -ne 1 -a ${REMOVE} -eq 1 ]; then
415376 YEP="n"
416377
417− if [ ${FORCE} -ne 1 ]
418− then
378+ if [ ${FORCE} -ne 1 ]; then
419379 echo -n "Are you sure you want to delete original? [y] >"
420380 read YEP
421381 fi
422382
423− if [ "${YEP}" = "y" -o ${FORCE} -eq 1 ]
424− then
383+ if [ "${YEP}" = "y" -o ${FORCE} -eq 1 ]; then
425384 rm -f "${FILE}"
426385 fi
427386 fi

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