[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cropping a large collection of .PNG screenshots



On Sun, Apr 13, 2014 at 2:26 AM, Steve Litt <slitt@troubleshooters.com> wrote:
> On Thu, 10 Apr 2014 00:43:45 +0300
> Andrei POPESCU <andreimpopescu@gmail.com> wrote:
>
>> On Mi, 09 apr 14, 08:59:51, Steve Litt wrote:
>> >
>> > Or, you can just redirect ls into a file, use Vim to convert and
>> > rename each file individually.
>>
>> Could you please elaborate on this?
>
> ls -1 *.png > doit.sh
> chmod a+x doit.sh
> gvim doit.sh
> :%s/^/doconvert  /
> ggi
> function doconvert(){
>  mv $1 $1.bak
>  convert -crop whatever $1.bak $1
> }<esc>
> :wq
> ./doit.sh

I'd just do that directly in bash.

for fn in *.png; do mv $fn $fn.bak; convert -crop whatever $fn.bak $fn; done

But that's assuming you know how to use 'convert -crop' to do what you
want, which I don't. Personally, I'd whip up a quick Pike script, or
even do the job at the Pike interactive prompt; but that's because I'm
familiar with Pike's image library. (Happy to elaborate if you're
curious, but unless you have Pike installed already, it'll almost
certainly be easier to use convert.)

ChrisA


Reply to: