Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Quick script request
Date: Wed, 25 Jun 2008 15:32:15
Message-Id: 200806251732.31906.alan.mckinnon@gmail.com
In Reply to: [gentoo-user] Quick script request by Grant
1 On Wednesday 25 June 2008, Grant wrote:
2 > Feel free to ignore me here, but if anyone could whip out a quick
3 > script for this I would really appreciate it.
4 >
5 > I need to move any files from dir1 to dir2 if they don't already
6 > exist in dir2 with a slightly different filename. The dir1 files are
7 > named like a-1.jpg and the dir2 files are named like
8 > a-1_original.jpg.
9 >
10 > - Grant
11
12 rough and ready, off the top of my head:
13
14 cd dir1
15 for i in *jpg
16 do
17 j = basename $i .jpg
18 cp -u ${j}.jpg dir2/${j}_original.jpg
19 done
20
21 'cp -u' works around the messy problem of checking if the destination
22 file exists
23
24 --
25 Alan McKinnon
26 alan dot mckinnon at gmail dot com
27
28 --
29 gentoo-user@l.g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Quick script request Grant <emailgrant@×××××.com>