rename appears useless in Ubuntu
anthony baldwin
photodharma at gmail.com
Wed May 13 12:31:50 UTC 2009
Heike C. Zimmerer wrote:
> anthony baldwin <baldwinlinguas at gmail.com> writes:
>
> Some comments:
>> #!/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)
>
> You don't use your variable i anywhere later. The whole loop is
> pointless. It would not even work if the variable i were used, since
> $(ls -1 $a) splits the string at every white space, you won't get
> filenames containing spaces through it.
Ah, but it DOES work, young paduan.
It does precisely what I want (or did in PCLOS, now, in ubuntu, I have
learned that I must use rename.ul rather than plain rename (which should
be prename), and it still works).
A working version would be
>
> for i in *."$a"
>
> Now:
>
>> do
>> rename \ _ *.$a
>
> With the for clause adjusted as depicted above, use
>
> mv "$i" "${i// /_}"
>
> here, and you should be done (not tested). As you wrote it, the rename
> command is called many times with the first call doing the real work and
> getting all the file names as arguments (*.$a), and the remaining calls
> being useless (but doing no harm) since there a no spaces in file names
> any more.
The first time, it removes the first space in each file name,
then the second, etc.
If I run it without the loop, it only removes the first space.
/tony
--
http://www.baldwinlinguas.com
tcl me...I like it like that!
More information about the ubuntu-users
mailing list