I have a bunch of video-files in one folder , that has a double suffix avi.avi.
find /home/alex/Filme/ -type f -name '*.avi.avi'
/home/alex/Filme/Super 8.avi.avi
/home/alex/Filme/Exit - A Night From Hell.avi.avi
/home/alex/Filme/Der Plan.avi.avi
/home/alex/Filme/Ich.bin.Nummer.4.2011.avi.avi
snipp
I try to remove the double string with following "Script"
#!/bin/bash
for i in `find $HOME/Filme -type f -name '*avi.avi' -print0`
do
sed -e 's/'*.avi.avi'/'*.avi'/g'
done
Or is a better way to achive this with rename, like this?
find $HOME/Filme -type f -name '*avi.avi' -print0 -exec sh -c rename -v 's/*.avi.avi/*.avi/g' {} \;
I'am not sure if the foldername will be preserved. Yes I found several questions and answers for this, but I have problems to adapt it to my case.
Does one of my approach work?
find "$HOME/Filme" -type f -name \*.avi.avi -exec rename -v 's/.avi$//' {} +
asrename
can take multiple arguments. – Jul 14 '17 at 10:26rename
isn't available on all systems so thesh
is better suited.+
there is GNUism but can easily be replaced by\;
for compatibility reasons – Valentin Bajrami Jul 14 '17 at 10:53