Index

Subject : Re: LUG: seeking elegant solution

From : ajoakes@ncsu.[redacted]

Date : Wed, 16 Nov 2011 22:19:25 -0500

Parent


The loop with modification worked perfectly thank you.

The whole story is that I was helping my girlfriend apply watermarks to about
800 jpegs which were split among 8-10 different directories. Using imagemagick
made this an easy task; set it and forget it, except we didn't realize until the
first 100 or so had been done that we set the opacity of the watermark
incorrectly.

She claimed to have back ups of all the original images, which was mostly true.
The trouble was that her backups were in a completely different dir structure.
Originals were in dirs labelled with the date and the finished images were named
by location. Several images from several dates made up the contents of each
location. The set we watermarked had been picked through so maybe only half of
the originals were destined to be watermarked, resized, etc.

The loop was a great solution. I'm going to have to look into this bash
scripting stuff to start really utilizing my machine. Thanks to everyone who
replied.

Cheers,
Aaron



On Wed, 16 Nov 2011, Stephen Roller wrote:

> Slight modification from Alex's post:
>
> for file in $(ls --color=none 2/); do cp 1/$file 2/$file; done
>
> The --color=none might not be necessary, but it was for me. The $ in
> front of the file inside the loop is definitely necessary.
>
> I would make backups of both directories before you do something you can't undo.
>
>
> On Wed, Nov 16, 2011 at 7:01 PM, Alex Ray <alexjray.ncsu@gmail.[redacted]> wrote:
>> Checkout bash for loops. I suspect you want something of the form :
>>
>> for file in $(ls 2/);
>> do
>> cp 1/file 2/file
>> done
>>
>> Cheers,
>> Alex
>>
>> On Nov 16, 2011 7:57 PM, "Aaron Oakes" <ajoakes@ncsu.[redacted]> wrote:
>>>
>>> I have what I think should be a pretty easy problem to solve.
>>>
>>> In directory 1 are files 1,2,3,4,5.
>>> Directory 2 contains files 2 and 4.
>>>
>>> All the files are jpeg images and the files in directory 2 have been
>>> modified more recently than those in directory 1.  I want to copy
>>> files 2 and 4 from directory 1 to directory 2.
>>>
>>> Based on my limited past experience with linux I have a hunch that
>>> there is a very elegant and efficient way to accomplish this task.
>>>
>>> Any thoughts?
>>>
>>> Thanks in advance.
>>>
>>> Cheers,
>>> Aaron
>>>
>>
>
>