Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

BASH rename Greek characters (upper, lower case)

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
ratrace
Posts: 26
Joined: 2015-04-23 07:52
Location: Athens, Greece
Has thanked: 1 time

BASH rename Greek characters (upper, lower case)

#1 Post by ratrace »

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.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

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

#2 Post by GarryRicketson »

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.

ratrace
Posts: 26
Joined: 2015-04-23 07:52
Location: Athens, Greece
Has thanked: 1 time

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

#3 Post by ratrace »

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.

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

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

#4 Post by GarryRicketson »

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..

peter_irich
Posts: 1403
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

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

#5 Post by peter_irich »

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.

Post Reply