Help

Renaming

Revision as of 09:16, 19 May 2018 by Yug (talk | contribs)

Using the file name's fields

Given files names such as ./{codeLang}-{word}-{speaker}-{id}.wav such as ./cmn-quan3-LL12087.wav :

mkdir -p ./new                                # create dir
for file in ./cmn-*.wav;
do 
   key=$(basename "$file" | cut -d- -f3);     # using "-" as split, select field 2 : "quan3"
   cp "$file" ./new/cmn-"$key".wav;           # ./new/cmn-quan3.wav
done