From owner-freebsd-questions@FreeBSD.ORG Fri Mar 27 03:47:34 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E0A61065670 for ; Fri, 27 Mar 2009 03:47:34 +0000 (UTC) (envelope-from david+dated+1238555693.f4db0d@skytracker.ca) Received: from 3s1.com (3s1.com [209.161.205.12]) by mx1.freebsd.org (Postfix) with ESMTP id 19D018FC23 for ; Fri, 27 Mar 2009 03:47:32 +0000 (UTC) (envelope-from david+dated+1238555693.f4db0d@skytracker.ca) Received: from 3s1.com (localhost [127.0.0.1]) by 3s1.com (8.13.8/8.13.8) with ESMTP id n2R3EreO020693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 26 Mar 2009 23:14:57 -0400 (EDT) (envelope-from david+dated+1238555693.f4db0d@skytracker.ca) Received: (from david@localhost) by 3s1.com (8.13.8/8.14.1/Submit) id n2R3ErbN020690 for questions@freebsd.org; Thu, 26 Mar 2009 23:14:53 -0400 (EDT) (envelope-from david+dated+1238555693.f4db0d@skytracker.ca) X-Authentication-Warning: 3s1.com: david set sender to david+dated+1238555693.f4db0d@skytracker.ca using -f Received: from [192.168.1.20] (twenty [192.168.1.20]) by 3s1.com (tmda-ofmipd) with ESMTP; Thu, 26 Mar 2009 23:14:38 -0400 Message-ID: <49CC44AC.6010401@skytracker.ca> Date: Thu, 26 Mar 2009 23:14:52 -0400 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Ramiro Caso References: <20090324195751.GA20259@skytracker.ca> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: David Banning X-Virus-Scanned: ClamAV 0.94.2/9171/Thu Mar 26 13:49:28 2009 on 3s1.com X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on 3s1.com Cc: questions@freebsd.org, david+dated+1238356671.fa5de5@skytracker.ca Subject: Re: renaming many Chinese files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2009 03:47:34 -0000 that worked fine. Thanks. > 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" > >