I have a multiples files with space, and I want replace this for a underscore with command line (Mac)
xxx xxx.jpg -> xxx_xxx.jpg
It's possible with only line command?
For all files in current directory
for i in *;do mv "$i" "${i// /_}";done
If you only want to match files with spaces (to prevent tons of error messages when it tries to move files into themselves) though you could use extended glob
shopt -s extglob
for i in +(* *);do mv "$i" "${i// /_}";done
mv -i
to avoid accidental overwritten files in bulk moves!
Jul 6, 2016 at 17:45