If you have
bash(1) 4.
x, you can use
globstar:
Code:
#!/bin/bash
shopt -s globstar
dir=$HOME/path/foo
for f in $dir/**/*; do
if [[ $f = *\;* ]]; then
mv -- "$f" "${f//;/ -}"
fi
done
You can also use a neat tool called
rename :
Code:
#!/bin/bash
shopt -s globstar
dir=$HOME/path/foo
rename 's/;/ -/g' dir/**/*
canit0 wrote:
The example below worked for me, but I don't know what others with more experience may think. I think its fine.
He wanted to rename his files, not to edit them.
So, with
find(1), you can do :
Code:
find $dir/ -type f -name '*;*' -print0 | while IFS= read -rd '' f; do mv -- "$f" "${f//;/ -}"; done