Reputation: 456
I'm wondering how to make mass rename (using rename or sed/awk), for files like this:
Name 1 - Name 2 - Name 3.doc
Name 1- Name 2 - Name 3.doc
Name 1 -Name 2 - Name 3.doc
the problem is that i want to have all files in the same schema, for example
Name 1-Name 2-Name 3.doc
without spaces at all. I'm reading rename documentation but can't find way to do this.
Upvotes: 1
Views: 100
Reputation: 77155
How about:
for file in *.doc; do
mv "$file" "$(sed 's# *- *#-#g' <<< "$file")"
done
Upvotes: 2
Reputation: 185570
Try doing this :
rename 's/\s*-\s*/-/g' *.doc
You need the Perl's rename
, see this post
Upvotes: 2