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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With