BASH rename Greek characters (upper, lower case)

Need help with C, C++, perl, python, etc?

BASH rename Greek characters (upper, lower case)

Postby ratrace » 2016-09-20 11:47

Hello,

I'm trying to rename files and directories names that are written in Greek. Specifically i want to change the first character of every file or folder and from upper case to make it lower case.
For example i want a folder with the Greek name 'Εισοδημα' to be changed to 'εισοδημα'. I tried in bash the command

Code: Select all
rename -n 's/^(.{1})/\l$1/' *

The above code changes the first character from upper to lower case letter, but only for files or folders written in English.

How can i make that work for Greek characters also?

Thanks
Last edited by ratrace on 2016-09-20 14:52, edited 2 times in total.
ratrace
 
Posts: 10
Joined: 2015-04-23 07:52
Location: Athens, Greece

Re: BASH rename Greek characters (upper, lower case)

Postby GarryRicketson » 2016-09-20 13:33

Did you try some searches ?

BASH rename Greek characters upper, lower case
---------------------------------------
Unless there is a reason it has to be "bash", 'perl' might be a better choice:
rename Greek characters upper, lower case using perl

Do you have the command 'rename' ?
Code: Select all
man rename

RENAME(1) Perl Programmers Reference Guide RENAME(1)

NAME
rename - renames multiple files

SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

DESCRIPTION
"rename" renames the filenames supplied according to the rule specified
as the first argument. The perlexpr argument is a Perl expression
which is expected to modify the $_ string in Perl for at least some of
the filenames specified. If a given filename is not modified by the
expression, it will not be renamed. If no filenames are given on the
command line, filenames will be read via standard input.

If you don't, you will need to install it, to use 'rename'. There are details on that
in the results of the first searches,...
Also in this thread/topic,
http://forums.debian.net/viewtopic.php?f=30&t=129864
The most recent post mentions: ' pyrenamer '
pyrenamer
mass file renamer written in PyGTK
-------------------------------------------
You can rename files using patterns, search and replace,
substitutions, insert or delete text, or even rename
files manually.
You can also rename images using their EXIF tags
and music using their internal tags

I don't know if it works very well, have never tried it myself,
Perl or bash is usually sufficient.
User avatar
GarryRicketson
 
Posts: 3861
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: BASH rename Greek characters (upper, lower case)

Postby ratrace » 2016-09-20 14:28

GarryRicketson if you read my question and you understand what i'm writing, you will see that i already tried rename command but the output is not exactly what i want. So the answer to you question 'Do you have the command 'rename'?' is of course i have it, because i already try it. And also i made a lot of searches to find the answer, but i didn't find it yet. If you have to add anything helpful it would be nice.

Thanks.
ratrace
 
Posts: 10
Joined: 2015-04-23 07:52
Location: Athens, Greece

Re: BASH rename Greek characters (upper, lower case)

Postby GarryRicketson » 2016-09-20 14:41

Ok, well sorry, I missed that,
is of course i have it, because i already try it.

---edited---- I see it now.-----
Please use code boxes, for the code. That is why it was missed, ..
I see now, you did post the code:
I tried in bash the command rename -n 's/^(.{1})/\l$1/' * and i can see that it changes the first characters to lower case but only for files or folders written with English characters. How can i make that work for Greek characters also?

If you use "code boxes" it is easier for us to read:

Code: Select all
rename -n 's/^(.{1})/\l$1/' *


My apology, and I am not sure, if it works for English characters, I don't know
why it wouldn't work for Greek as well..
User avatar
GarryRicketson
 
Posts: 3861
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: BASH rename Greek characters (upper, lower case)

Postby peter_irich » 2016-09-20 20:37

tr can change upper to low or otherwise, man tr.
For example:
Code: Select all
#!/bin/tcsh

foreach  flnm ( `ls` )
if ( -f $flnm) then
mv -f $flnm `echo $flnm|tr '[A-Z]' '[a-z]' `
endif
end

Or "ls -1" and "$flnm".

Peter.
peter_irich
 
Posts: 1162
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation


Return to Programming

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable