Help
Renaming
Renaming using the file name's fields
Given files names such as ./{codeLang}-{word}-{speaker}-{id}.wav
such as ./cmn-quan3-Can_Yue-LL12087.wav
:
mkdir -p ./new # create dir
for file in ./cmn-*.wav;
do
key=$(basename "$file" | cut -d- -f2); # using "-" as split, select field 2 : "quan3"
cp "$file" ./new/cmn-"$key".wav; # ./new/cmn-quan3.wav
done
Renaming using metadata
Dependencies
sudo apt-get install lame avconv # examine audio file's properties.
avconv's output
avconv -i ./cmn-jiāoliú.flac 2>&1 # print out metadata of $file, for some formats only ffmpeg version 2.8.14-0ubuntu0.16.04.1 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609 [...] Input #0, flac, from './cmn-jiāoliú.flac': Metadata: TITLE : 交流 LICENSE : Creative Commons BY-SA 3.0 U.S COPYRIGHT : (c) 2009 Yue Tan ARTIST : Tan DATE : 2009-07-08 GENRE : Speech SWAC_LANG : cmn SWAC_TEXT : 交流 SWAC_ALPHAIDX : jiāoliú SWAC_SPEAK_NAME : Tan SWAC_SPEAK_GENDER: F SWAC_SPEAK_BIRTH_YEAR: 1978 SWAC_SPEAK_LANG : zho SWAC_SPEAK_LANG_REGION: Liaoning SWAC_SPEAK_LIV_COUNTRY: FR SWAC_SPEAK_LIV_TOWN: Caen SWAC_PRON_PHON : jiāoliú SWAC_COLL_SECTION: HSK niveau II SWAC_COLL_LICENSE: Creative Commons BY-SA 3.0 U.S SWAC_COLL_COPYRIGHT: (c) 2009 Yue Tan SWAC_TECH_DATE : 2009-07-08 SWAC_TECH_SOFT : Shtooka Recorder/1.3 Duration: 00:00:01.40, start: 0.000000, bitrate: 447 kb/s Stream #0:0: Audio: flac, 44100 Hz, mono, s16
Renaming
mkdir -p ./new # create dir
for file in ./cmn-*.flac;
do
key=$(avconv -i "$file" 2>&1 | sed -ne 's/.*SWAC_TEXT *: //p') # print metadata, assign SWAC_TEXT's value to variable.
cp "$file" ./cmn-$key.flac # ./cmn-交流.flac
done
See also
- Help:SoX - audio clean up (denoise) and others