1 |
>> >> > cd dir1 |
2 |
>> >> > for i in *jpg |
3 |
>> >> > do |
4 |
>> >> > j = basename $i .jpg |
5 |
>> >> > cp -u ${j}.jpg dir2/${j}_original.jpg |
6 |
>> >> > done |
7 |
>> >> > |
8 |
>> >> > 'cp -u' works around the messy problem of checking if the |
9 |
>> >> > destination file exists |
10 |
> [...] |
11 |
>> I put the above script in a file, added the appropriate header, issued |
12 |
>> chmod, and when I execute with ./file I get a bunch of these: |
13 |
>> |
14 |
>> ./script: line 6: j: command not found |
15 |
>> cp: cannot stat `.jpg': No such file or directory |
16 |
> |
17 |
> This: |
18 |
> j = basename $i .jpg |
19 |
> should be more like this: |
20 |
> j=$( basename $i .jpg ) |
21 |
> |
22 |
> Or: j=${i%.jpg} |
23 |
> |
24 |
> That is, there must be no whitespace around the '='. And in order to set j |
25 |
> to the result of a command, use $( command ) or ` command `. |
26 |
|
27 |
Worked perfectly, thanks a lot everyone. |
28 |
|
29 |
- Grant |
30 |
-- |
31 |
gentoo-user@l.g.o mailing list |