On Wednesday 25 June 2008, 17:08, 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
> like a-1.jpg and the dir2 files are named like a-1_original.jpg.

Try this (untested)

#!/bin/bash

cd /dir1

for i in *; do
  if [ ! -f "/dir2/$i" ]; then
    bn=${i%.*}
    ext=${i##*.}
    nn=${bn}_original.${ext}
    mv -- "$i" "/dir2/$nn"
  fi

done


For each file in dir1, say a-1.jpg, this look if a file with the same 
name exists in dir2. If not, it moves it to dir2 with the new name of 
a-1_original.jpg. I hope I got that right.
-- 
gentoo-user@lists.gentoo.org mailing list

Reply via email to