History

special 'underscored' tags to replace spaces with underscores

Serge Zirukin committed 14 years ago

Commit fe1f5a21 parent 14dd08a1 file · +17 −4Browse files

Showing the changes to split2flac (1 of 1 file). Show all

Unified · Split

split2flac+17−4
@@ -67,7 +67,7 @@ unset PIC INPATH CUE CHARSET · 66 unmodified lines
6767 FORCE=0
6868
6969 # do not forget to update before commit
70−VERSION=111
70+VERSION=112
7171
7272 HELP="\${cG}split2flac version: ${VERSION}
7373 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.
@@ -108,6 +108,8 @@ Usage: \${cZ}split2\${FORMAT} [\${cU}OPTIONS\$cZ] \${cU}FILE\$cZ [\${cU}OPTIONS\ · 34 unmodified lines
108108 Supported tags for \$cU\${cG}PATTERN\${cZ}: @artist, @album, @year, @track, @performer, @title, @genre, @ext.
109109 @performer tag is useful with 'various artists' albums, when you want to add
110110 each artist's name to the track filename. It works as @artist if track performer is undefined.
111+Special \"underscored\" tags are also supported (@_artist, @_album, etc). If used, spaces will be replaced with
112+underscores. It's useful if you want to have filenames without spaces.
111113
112114 It's better to pass \$cP'-p'\$cZ option to see what will happen when actually splitting tracks.
113115 You may want to pass \$cP'-s'\$cZ option for the first run to save default configuration
@@ -251,15 +253,26 @@ fi · 137 unmodified lines
251253
252254 $msg "${cG}Output dir :$cZ ${DIR:?Output directory was not set}\n"
253255
256+# replaces a tag name with the value of the tag. $1=pattern $2=tag_name $3=tag_value
257+update_pattern_aux () {
258+ tag_name="$2"
259+ tag_value="$3"
260+ expr_match="@${tag_name}"
261+ expr_match_opt="[{]${expr_match}\([^}]*\)[}]"
262+
263+ echo "$1" | { [ "${tag_value}" ] \
264+ && sed "s/${expr_match_opt}/${tag_value}\1/g;s/${expr_match}/${tag_value}/g" \
265+ || sed "s/${expr_match_opt}//g;s/${expr_match}//g"; }
266+}
267+
254268 # replaces a tag name with the value of the tag. $1=pattern $2=tag_name $3=tag_value
255269 update_pattern () {
256270 # replace '/' with '\' and '&' with '\&' for proper sed call
257271 tag_name=$(echo "$2" | sed 's,/,\\\\,g;s,&,\\&,g')
258272 tag_value=$(echo "$3" | sed 's,/,\\\\,g;s,&,\\&,g')
259273
260− echo "$1" | { [ "$3" ] \
261− && sed "s/[{]@${tag_name}\([^}]*\)[}]/${tag_value}\1/g;s/@${tag_name}/${tag_value}/g" \
262− || sed "s/[{]@${tag_name}\([^}]*\)[}]//g;s/@${tag_name}//g"; }
274+ v=$(update_pattern_aux "$1" "${tag_name}" "${tag_value}")
275+ update_pattern_aux "$v" "_${tag_name}" $(echo "${tag_value}" | sed "s/ /_/g")
263276 }
264277
265278 # splits a file

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