[gentoo-user] Quick script request

2008-06-25 Thread Grant
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

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alex Schuster
Grant asks: Feel free to ignore me here, but if anyone could whip out a quick script for this I would really appreciate it. Whipped. Be sure to test it, because I did not :) Remove the echo statement when you are sure it works. I need to move any files from dir1 to dir2 if they don't

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alan McKinnon
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

Re: [gentoo-user] Quick script request

2008-06-25 Thread Grant
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

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alex Schuster
Grant asks: Thanks guys, can you tell me how to execute this? Put it in a file and './file' I think? Should I have special stuff at the top of the file? Yes, a '#!/bin/bash', it you want top have thsi as a script. You need to make it executable, too: chmod +x file But you can also leave

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alan McKinnon
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

Re: [gentoo-user] Quick script request

2008-06-25 Thread Grant
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

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alex Schuster
Grant asks: 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 [...] I put the above script in a file, added the appropriate header, issued chmod,

Re: [gentoo-user] Quick script request

2008-06-25 Thread Grant
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 [...] I put the above script in a file, added the appropriate header, issued chmod, and when I

Re: [gentoo-user] Quick script request

2008-06-25 Thread Alan McKinnon
On Wednesday 25 June 2008, Grant wrote: This: j = basename $i .jpg should be more like this: j=$( basename $i .jpg ) Or: j=${i%.jpg} That is, there must be no whitespace around the '='. And in order to set j to the result of a command, use $( command ) or `

Re: [gentoo-user] Quick script request

2008-06-25 Thread Daniel Iliev
On Wed, 25 Jun 2008 22:42:47 +0200 Alan McKinnon [EMAIL PROTECTED] wrote: Isn't there a little known and unused but very useful command that already does this? This type of usage often comes up on mailing lists and invariably someone mentions it after 20 posts or so, but I can never