On Wednesday 25 June 2008, Grant wrote:
> >> Feel free to ignore me here, but if anyone could whip out a quick
> >> script for this I would really appreciate it.
> >>
> >> I need to move any files from dir1 to dir2 if they don't already
> >> exist in dir2 with a slightly different filename. The dir1 files
> >> are named like a-1.jpg and the dir2 files are named like
> >> a-1_original.jpg.
> >>
> >> - Grant
> >
> > rough and ready, off the top of my head:
> >
> > cd dir1
> > for i in *jpg
> > do
> > j = basename $i .jpg
> > cp -u ${j}.jpg dir2/${j}_original.jpg
> > done
> >
> > 'cp -u' works around the messy problem of checking if the
> > destination file exists
>
> Thanks guys, can you tell me how to execute this? Put it in a file
yes
> and './file' I think?
Either that or chmod a+x file and execute it directly
> Should I have special stuff at the top of the
> file?
#!/bin/bash
--
Alan McKinnon
alan dot mckinnon at gmail dot com
--
[email protected] mailing list