L
L
L_V_S2014-07-23 11:27:41
bash
L_V_S, 2014-07-23 11:27:41

How to remove ".wav" from filename in find output. -name "*.wav"?

wrote a small script for batch transcoding files from wav to mp3

#!/bin/bash
for i in $(find . -name "*.wav");
do
  file=$i
  lame -b 16  $file $file.mp3
done

The script is run from the folder numbers
/numbers
/905xxxxxx #phone number
---/2014 #folder year
---/06 #folder month
---/22 #folder date
12_01_file.wav
12_05_file.wav
---/07
13_01_file.wav
After the script is executed, the files are converted like this 12_01_file.wav.mp3
How and where is it better to remove .wav in the script and get 12_01_file.mp3 ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Petrikov, 2014-07-23
@L_V_S

Option 1:
Replace the line
with
AND in the transcoder line do
Option 2:
After the line
do

mv $file.mp3 $(echo "$file.mp3" | sed 's/\.wav//g')

S
ShamblerR, 2015-02-18
@ShamblerR

find . -name '*\.wav' | sed 's/\.wav//g'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question