Could you please try following once. Following will only print the rename commands on screen, you could run 1 command from it and if you are happy with results then you could run my 2nd code.
find . -type f -name "*.aiff*" -print0 |
while IFS= read -r -d '' file
do
echo "$file" |
awk '
BEGIN{ s1=""" }
{ val=$0; sub(/^.//,""); sub(/.aiff/,"."$2"&",$1)
print "mv " s1 val s1 OFS $1
}'
done
OR in case you want to put condition and check if file name has space or not so put an additional condition in awk
command it will skip files which are not having space in their names.
find . -type f -name "*.aiff*" -print0 |
while IFS= read -r -d '' file
do
echo "$file" |
awk '
BEGIN{ s1=""" }
NF==2{ val=$0; sub(/^.//,""); sub(/.aiff/,"."$2"&",$1)
print "mv " s1 val s1 OFS $1
}'
done
Run following only after you have tested above code successfully please.
find . -type f -name "*.aiff*" -print0 |
while IFS= read -r -d '' file
do
echo "$file" |
awk '
BEGIN{ s1=""" }
{ val=$0; sub(/^.//,""); sub(/.aiff/,"."$2"&",$1)
print "mv " s1 val s1 OFS $1
}' | sh
done
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…