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
67FORCE=067FORCE=0
68 68
69# do not forget to update before commit69# do not forget to update before commit
70VERSION=11170VERSION=112
71 71
72HELP="\${cG}split2flac version: ${VERSION}72HELP="\${cG}split2flac version: ${VERSION}
73Splits 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.73Splits 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
108Supported tags for \$cU\${cG}PATTERN\${cZ}: @artist, @album, @year, @track, @performer, @title, @genre, @ext.108Supported tags for \$cU\${cG}PATTERN\${cZ}: @artist, @album, @year, @track, @performer, @title, @genre, @ext.
109@performer tag is useful with 'various artists' albums, when you want to add109@performer tag is useful with 'various artists' albums, when you want to add
110each artist's name to the track filename. It works as @artist if track performer is undefined.110each artist's name to the track filename. It works as @artist if track performer is undefined.
111Special \"underscored\" tags are also supported (@_artist, @_album, etc). If used, spaces will be replaced with
112underscores. It's useful if you want to have filenames without spaces.
111 113
112It's better to pass \$cP'-p'\$cZ option to see what will happen when actually splitting tracks.114It's better to pass \$cP'-p'\$cZ option to see what will happen when actually splitting tracks.
113You may want to pass \$cP'-s'\$cZ option for the first run to save default configuration115You may want to pass \$cP'-s'\$cZ option for the first run to save default configuration
@@ -251,15 +253,26 @@ fi · 137 unmodified lines
251 253
252$msg "${cG}Output dir :$cZ ${DIR:?Output directory was not set}\n"254$msg "${cG}Output dir :$cZ ${DIR:?Output directory was not set}\n"
253 255
256# replaces a tag name with the value of the tag. $1=pattern $2=tag_name $3=tag_value
257update_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
254# replaces a tag name with the value of the tag. $1=pattern $2=tag_name $3=tag_value268# replaces a tag name with the value of the tag. $1=pattern $2=tag_name $3=tag_value
255update_pattern () {269update_pattern () {
256 # replace '/' with '\' and '&' with '\&' for proper sed call270 # replace '/' with '\' and '&' with '\&' for proper sed call
257 tag_name=$(echo "$2" | sed 's,/,\\\\,g;s,&,\\&,g')271 tag_name=$(echo "$2" | sed 's,/,\\\\,g;s,&,\\&,g')
258 tag_value=$(echo "$3" | sed 's,/,\\\\,g;s,&,\\&,g')272 tag_value=$(echo "$3" | sed 's,/,\\\\,g;s,&,\\&,g')
259 273
260 echo "$1" | { [ "$3" ] \274 v=$(update_pattern_aux "$1" "${tag_name}" "${tag_value}")
261 && sed "s/[{]@${tag_name}\([^}]*\)[}]/${tag_value}\1/g;s/@${tag_name}/${tag_value}/g" \275 update_pattern_aux "$v" "_${tag_name}" $(echo "${tag_value}" | sed "s/ /_/g")
262 || sed "s/[{]@${tag_name}\([^}]*\)[}]//g;s/@${tag_name}//g"; }
263}276}
264 277
265# splits a file278# 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