Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Mar 2009 19:07:57 -0300
From:      Ramiro Caso <misha_78@hotmail.com>
To:        <david+dated+1238356671.fa5de5@skytracker.ca>, <questions@freebsd.org>
Subject:   RE: renaming many Chinese files
Message-ID:  <BAY102-W44AE807B7E59EEF75E0ED3E1930@phx.gbl>
In-Reply-To: <20090324195751.GA20259@skytracker.ca>
References:  <20090324195751.GA20259@skytracker.ca>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

Just a very quick thought (the first that pops into my mind): you could
see which are the western characters that appear in the names=2C and then
use sed to substitute all non-matching characters with nothing=2C
something like:

for i in *.jpg=3B do b=3D"`echo $i | sed 's/[^CHAR_SET]//g'`"=3B mv $i $b=
=3B done

(without
forgetting=2C obviously=2C to add . to the CHAR_SET=2C something like:
[^a-zA-Z0-9.]=3B if you figure out a less clumsy way=2C please=2C share!!)
I'm guessing that the initial 'P123' is just an example=2C or this will
horribly backfire. But I'm really=2C REALLY=2C taking a shot in the dark
here... (if you already thought of this=2C and it just doesn't work=2C
sorry for the useless pitch)


> Date: Tue=2C 24 Mar 2009 15:57:51 -0400
> To: questions@freebsd.org
> From: david+dated+1238356671.fa5de5@skytracker.ca
> CC:=20
> Subject: renaming many Chinese files
>=20
> I have hundreds of jpg images where each image is named P123****.jpg
> where the **** are chinese characters. I can't open the file - it
> has to be renamed before I can open it. Evening if I could open it
> I don't want the Chinese part as the name.
>=20
> Each file starts with 3 or four western characters and then has 3 or
> four chinese characters=2C before the western .jpg extension.
>=20
> I want to to test each filename character by character
> to see if it is western=2C and then when the first Chinese Character is=20
> found=2C have it simply rename the file to the 3 or four western-characte=
r=20
> name + .jpg
>=20
> I can write most of the script but I don't know how to test for=20
> western and/or Chinese characters.
> =20
> I could run a script that would simply rename all the files to=20
> a number in sequential order but I would rather use the existing
> starting name of the file if possible.
>=20
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe=2C send any mail to "freebsd-questions-unsubscribe@freebsd=
.org"

_________________________________________________________________
Encontr=E1 el auto de tus sue=F1os en MSN=20
http://xml.mercadolibre.com.ar/org-img/msn/autos.html=



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?BAY102-W44AE807B7E59EEF75E0ED3E1930>