You are not logged in.
Pages: 1
Hello everyone!
I'm loving this Arch install. Things have never worked more solidly since my move to linux a few years ago.
However, I'm stumped with this relatively find -exec script that used to work on default debian/ubuntu:
find . -name "* *" -exec rename 's/\ /_/g' {} \;
It keeps telling me find needs a path declared...and rename doesn't like the arguements. I'm just running it from the location I want to comb for spaces in filenames. Maybe I'm not remembering the syntax properly? Or is 's/\ /_/g' {} \; actually a bit of Perl, and that isn't utilized by bash? Excuse me here, I'm pretty new to the more scripty commands...
Offline
man rename
Offline
Not sure if you're referring to the right rename, I've seen quite a bit confusion as there's also a popular perl rename.
Try
nospace () {
for i in *; do
OLDNAME="$i"
NEWNAME=$(echo "$i" | tr ' ' '_' | tr A-Z a-z | sed 's/_-_/-/g')
mv -v -- "$OLDNAME" "$NEWNAME"
done;
}
Adjust as needed.
Last edited by karol (2011-10-05 02:28:29)
Offline
Thanks for the input! I'm still learning the bash, obviously, and most of what I'm doing is still by rote. I know less about perl, so I'm going to hit the books for a bit.
Offline
Pages: 1