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 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.
cd $dir1
for file in *
do
if ! [[ -f $dir2/${file%.*}_original.${file##*.} ]]
then
echo mv -v "$file" "$dir2/"
fi
done
Loop over all files. If not exists a file called dir2/${file%.*}_original.
${file##*/}, move $file. ${file%.*} removes the suffix from $file
(everything from the last dot on), while ${file##*.} removes everything
until the dot, leaving the suffix only. Be sure to use the correct path for
dir2, either absolute or with some ../ in it.
Alex
--
[email protected] mailing list