From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id BC0471381F3 for ; Fri, 21 Dec 2012 05:21:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1CF0721C115; Fri, 21 Dec 2012 05:21:01 +0000 (UTC) Received: from mail119c7.megamailservers.com (mail119c7-2520.megamailservers.com [69.49.98.26]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1F772E06B5 for ; Fri, 21 Dec 2012 05:19:02 +0000 (UTC) X-POP-User: admin.sys-concept.com Received: from syscon7.localdomain (S01060050da7ae68c.ed.shawcable.net [68.149.90.13]) by mail119c7.megamailservers.com (8.13.6/8.13.1) with ESMTP id qBL5J1XI005255 for ; Fri, 21 Dec 2012 00:19:02 -0500 Received: by syscon7.localdomain (Postfix, from userid 1000) id 5DD6F20072C; Thu, 20 Dec 2012 22:19:47 -0700 (MST) Date: Thu, 20 Dec 2012 22:19:47 -0700 From: Joseph To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] copy resize files with directories Message-ID: <20121221051947.GG22445@syscon7.inet> References: <20121221050738.GF22445@syscon7.inet> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline In-Reply-To: <20121221050738.GF22445@syscon7.inet> User-Agent: Mutt/1.5.21 (2010-09-15) X-CSC: 0 X-CHA: v=1.1 cv=M/OfXiUT3yXeNaOuONSOHRsfWHstuXXEwp4jCZzxbHU= c=1 sm=1 a=wom5GMh1gUkA:10 a=ZiVfzLcZF1YA:10 a=nDghuxUhq_wA:10 a=8nJEP1OIZ-IA:10 a=C3ZDv51cNVt4vJz/79I2xQ==:17 a=bHkSqI81n-U_iGo3LmQA:9 a=wPNLvfGTeEIA:10 a=C3ZDv51cNVt4vJz/79I2xQ==:117 X-CTCH-Spam: Unknown X-CTCH-RefID: str=0001.0A020201.50D3F146.0068,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-Archives-Salt: a65cd9a4-b1f6-47e3-9c3f-1b123e4af411 X-Archives-Hash: e9f762be69e3e012c702186fab001d2e On 12/20/12 22:07, Joseph wrote: >I've found this script that copy and resize file on the fly from one location to another. > >for INPUT in ./*.JPG; do OUTPUT=/media/stick/`echo $INPUT | sed 's/\.JPG/\_new\.JPG/'`; echo $INPUT /media/stick/$OUTPUT; convert $INPUT -scale 800x $OUTPUT; done > >I go into each directory manually and run this command, however my camera was originally >set to start the same file name every time I empty it so I have the same file name in may directories (the are not unique) so every time I run this script it re-writes >the original one. > >The ideal situation would be go into each directory and create the same director directory on the destination disk with modified files >Can anybody suggest how can I rewrite this script to copy files together with directory or change the file to a unique one. > >I would like to span all directory I'm IN and bellow and run that script on any directory below. I do I combine the script above with this one below: find . -maxdepth 1 -type f -name "*rospslpar*" |while read filename; do path_name=${filename%/*} base_name=${filename##*/} new_name="$(expr substr $base_name 14 6).jpg" mv "$filename" "$path_name/$new_name" done It would help be rename the file with unique name. -- Joseph