I want to change the extensions of a folder full of files (some of the files are located in subfolders as well) to another extension, but instead of replacing the files I want the new files to be copied into a newly created folder.
Here is the folder structure:
/Downloads/3eb
/Downloads/3eb/album1
/Downloads/3eb/album2
/Downloads/3eb/album3
/Downloads/3eb/newdir
In each album1 folder there are .flac files, and I want to convert them all to .mov files and copied to /Downloads/3eb/newdir. Does that make sense?
I have tried the following command ran after cd'ing to /Downloads/3eb, but it returns an error (to follow):
for file in album*/*.flac ; do mv "$file" "newdir/`echo $file | sed 's/\(.*\.\)flac/\1mov/'`" ; done
The error:
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/05 - One in Ten.flac': No such file or directory
Can anyone help?
cd /Downloads/3eb/
for file in album*/*.flac
do
nf=${file#*/}
mv "$file" "newdir/${nf%flac}mov"
done
Thanks cfajohnson,
When I type that in the command prompt and hit enter after typing done, it runs through every file giving the same error (here's a snippet):
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/09 - Water Landing.flac': No such file or directory
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/10 - Dao of St. Paul.flac': No such file or directory
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/11 - Monotov's Private Opera.flac': No such file or directory
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/12 - Carnival Barker (Instrumental).flac': No such file or directory
mv: cannot rename 'Third Eye Blind - Ursa Major 2009/13 - Why Can't You Be (With Kimya Dawson).flac': No such file or directory
What did I do wrong?
It works for me.
Did you cut and paste or retype it?
If you retyped it, you probably made a typo.