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 |