Date: Fri, 27 Mar 2009 13:42:01 -0300 From: Ramiro Caso <misha_78@hotmail.com> To: <david+dated+1238555693.f4db0d@skytracker.ca> Cc: questions@freebsd.org Subject: RE: renaming many Chinese files Message-ID: <BAY102-W35465D33BF4CC2424D6CDAE18E0@phx.gbl> In-Reply-To: <49CC44AC.6010401@skytracker.ca> References: <20090324195751.GA20259@skytracker.ca> <BAY102-W44AE807B7E59EEF75E0ED3E1930@phx.gbl> <49CC44AC.6010401@skytracker.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
> Date: Thu, 26 Mar 2009 23:14:52 -0400 > To: misha_78@hotmail.com > From: david+dated+1238555693.f4db0d@skytracker.ca > CC: questions@freebsd.org; david+dated+1238356671.fa5de5@skytracker.ca > Subject: Re: renaming many Chinese files > > that worked fine. Thanks. Glad it did. And sorry for the top-posting before (kind of new at this) > > 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, and then > > use sed to substitute all non-matching characters with nothing, > > something like: > > > > for i in *.jpg; do b="`echo $i | sed 's/[^CHAR_SET]//g'`"; mv $i $b; done > > > > (without > > forgetting, obviously, to add . to the CHAR_SET, something like: > > [^a-zA-Z0-9.]; if you figure out a less clumsy way, please, share!!) > > I'm guessing that the initial 'P123' is just an example, or this will > > horribly backfire. But I'm really, REALLY, taking a shot in the dark > > here... (if you already thought of this, and it just doesn't work, > > sorry for the useless pitch) > > > > > > > >> Date: Tue, 24 Mar 2009 15:57:51 -0400 > >> To: questions@freebsd.org > >> From: david+dated+1238356671.fa5de5@skytracker.ca > >> CC: > >> Subject: renaming many Chinese files > >> > >> 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. > >> > >> Each file starts with 3 or four western characters and then has 3 or > >> four chinese characters, before the western .jpg extension. > >> > >> I want to to test each filename character by character > >> to see if it is western, and then when the first Chinese Character is > >> found, have it simply rename the file to the 3 or four western-character > >> name + .jpg > >> > >> I can write most of the script but I don't know how to test for > >> western and/or Chinese characters. > >> > >> I could run a script that would simply rename all the files to > >> a number in sequential order but I would rather use the existing > >> starting name of the file if possible. > >> > >> _______________________________________________ > >> freebsd-questions@freebsd.org mailing list > >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions > >> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > >> > > > > _________________________________________________________________ > > Encontrá el auto de tus sueños en MSN > > http://xml.mercadolibre.com.ar/org-img/msn/autos.html_______________________________________________ > > freebsd-questions@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > > > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" _________________________________________________________________ ¿Querés saber cómo va a estar el clima mañana? Ingresá ahora a MSN http://tiempo.ar.msn.com/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BAY102-W35465D33BF4CC2424D6CDAE18E0>
