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 |
7 |
> >> are 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 |
22 |
> > destination file exists |
23 |
> |
24 |
> Thanks guys, can you tell me how to execute this? Put it in a file |
25 |
|
26 |
yes |
27 |
|
28 |
> and './file' I think? |
29 |
|
30 |
Either that or chmod a+x file and execute it directly |
31 |
|
32 |
> Should I have special stuff at the top of the |
33 |
> file? |
34 |
|
35 |
#!/bin/bash |
36 |
|
37 |
-- |
38 |
Alan McKinnon |
39 |
alan dot mckinnon at gmail dot com |
40 |
|
41 |
-- |
42 |
gentoo-user@l.g.o mailing list |