? renaming files using the command line

In principle the command line would be a mighty tool to rename files,
but I just don’t seem to know the right commands,
and google searches in that respect don’t seem to be very elucidating.

The problem:
I have to rename about 500 files.
The file names have upper case letters, and I would like to change them
to lowercase letters.

So I thought that commands like

mv CMBSY*.* cmbsy*.*

would be a good idea, but then I get

mv: given destination „cmbsy*.*“ is not a directory

(translated).

On the other hand, using

rename CMBSY*.* cmbsy*.*

there aren’t any complaints, but just as well, NOTHING happens.

Even DOS had the command `ren’ that would have made it,
but with bash / Linux ?

For many of you this probably is a trivial task.

Thanks
Mike

On Mon, 02 Dec 2013 20:06:01 +0000, ratzi wrote:

> So I thought that commands like

man rename

mv (move) doesn’t accept wildcards. Rename does:

rename [from] [to] [wildmat]

For example, given a directory with files:

text1.txt
text2.txt
text3.txt
text4.txt

If you want to rename them so the files are:

file1.txt
file2.txt
file3.txt
file4.txt

the command is:

rename text file text*.txt

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Jim Henderson wrote:

> For example, given a directory with files:
>
> text1.txt
> text2.txt
> text3.txt
> text4.txt
>
> If you want to rename them so the files are:
>
> file1.txt
> file2.txt
> file3.txt
> file4.txt
>
> the command is:
>
> rename text file text*.txt
>

Thanks, Jim. For all the time I’ve been using Linux, I never realized that
the proper command format was more of a simple text string replacement op
than a fullname-to-fullname operation!


Will Honea

Hi Jim!

rename in my case didn’t seem to work,
see 1st post.

May be that is because I just want to replace uppercase letters
in the filenames by lowercase letters, whithout changing the
file name truely itself.

Thank you
Mike

What did you try, exactly? It can do this too but your use of ‘rename’
was incorrect so follow Jim’s example to have it work:

Code:

rename CMBSY cmbsy CMBSY*


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Hi ratzi,

If doing it on CLI isn’t mandatory, just to get the job done you may try krename from OSS repo (supposed you use KDE).
It has many functions and one of them is to just change the name into lower case letters. I have just checked.

rds

kasi

PS:
I know the I-want-to-get-this-working-in-exacly-that-way-!-feeling. Should this apply, just feel free to ignore to above advice.

On Mon, 02 Dec 2013 21:09:51 +0000, Will Honea wrote:

> Thanks, Jim. For all the time I’ve been using Linux, I never realized
> that the proper command format was more of a simple text string
> replacement op than a fullname-to-fullname operation!

That’s what happens when you have a CLI geek helping out. :wink:

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On Mon, 02 Dec 2013 21:26:01 +0000, ratzi wrote:

> Hi Jim!
>
> rename in my case didn’t seem to work,
> see 1st post.
>
> May be that is because I just want to replace uppercase letters in the
> filenames by lowercase letters, whithout changing the file name truely
> itself.

You used wildcards in your example. Don’t do that. As ab said, you need
to use the proper format - your example uses “rename [from] [to]” using
wildcards, and that is incorrect. Wildcards go in the third parameter,
which is actually a filespec. The first two are, as Will says, just
strings denoting the old string value and the new string value to change
it to.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

Hi Jim, hi Will,

to me the form of the command is really unusually.

But it works !

Before renaming, from ls, I have the file names

CMR10.pfb  CMR12.pfb  CMR17.pfb  CMR5.pfb  CMR6.pfb  CMR7.pfb  CMR8.pfb  CMR9.pfb

Then I enter the command

rename CMR cmr CMR*.pfb

Afterwards ‘ls’ gives

cmr10.pfb  cmr12.pfb  cmr17.pfb  cmr5.pfb  cmr6.pfb  cmr7.pfb  cmr8.pfb  cmr9.pfb

Sorry Jim, if I didn’t get you immediately.

Thanks a lot
Mike

On Mon, 02 Dec 2013 23:36:01 +0000, ratzi wrote:

> Sorry Jim, if I didn’t get you immediately.

That’s OK - you got it this time around. :slight_smile:

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2013-12-02 21:06, ratzi wrote:
>
> In principle the command line would be a mighty tool to rename files,
> but I just don’t seem to know how the right commands,
> and google searches in that respect don’t seem to be very elucidating.

I see you got the issue solved, but just in case:

krename - A Powerful Batch Renamer for KDE
gprename - A GTK2 batch renamer for files and directories

And there is another one I can not locate, like multiple move or
multiple rename.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)