rename appears useless in Ubuntu
anthony baldwin
baldwinlinguas at gmail.com
Thu May 7 03:20:10 UTC 2009
Greetings,
I have a little script to remove spaces from file names, and it was
working when I was using PCLinuxOS, but not on Ubuntu.
I used to be able to cd to a dir and do "nospace"(what I named the
script), and it would ask me for a file extension, remove the space, and
ask for a cookie. But on Ubuntu it does not rename the spaces.
I can't figure for the life of me why...
Here it is:
#!/bin/bash
# nospace
# replace spaces with underscores
echo "What kind of files do you wish to rename. Please enter the file
extension:"
read a
for i in $(ls -1 *$a)
do
rename \ _ *.$a
done
ls -1 *$a
echo "All done. Gimme a cookie!"
exit
I have also tried to simply do
rename \ _ *.pdf (or whatever extension)
, which, to my knowledge, without the loop, would remove the first
space in any such file name, and have to be repeated, of course, to
remove all spaces,
but, it does nothing.
I get no errors, but I also get no results.
It appears to read the variable "a" for the file extension, and
ls -1 *$a seems to list the files of that extension.
So, the only thing that isn't productive here is rename.
I've even tried to do
rename pdf PDF *.pdf
just to test rename, then I get an error, which I would not have seen in
PCLOS.
In PCLOS, this would have changed file.pdf to file.PDF without a hiccough.
In Ubuntu I get "Bareword "pdf" not allowed while "strict subs" in use
at (eval 1) line 1."
So, apparently I'm confused about why rename seems completely useless in
Ubuntu.
Thanks.
/tony
--
http://www.baldwinlinguas.com
translations & interpreting
More information about the ubuntu-users
mailing list