Hi. I really know very little about linux scripting. And I need help writing this script. The script is to get one parameter which is <directory>. And than the following will ensue;

for each image within directory
[INDENT]if not(image exist in temp-directory)
[INDENT]cp image to temp-directory and resize to 1024 pixels[/INDENT]

And I have a slight other problem :( the names may contain spaces and parenthesis I will need to somehow get over that barrier too.

Any help would be welcomed.

Thank you in advance

I think this has to be moved to shell scripting? Sorry for the trouble... :(

I wrote I python script for what I want but I would rather have a shell version as the Python version is dirty...

#! /usr/bin/python
# This Python file uses the following encoding: utf-8

#argv[1] needs to be send formatted meaning spaces and paranthesis

import os
import sys

__date__ ="$Aug 16, 2010 1:36:23 PM$"


#for turkish characters
def tr(utf):
    return utf.decode('utf-8')

img_directory_orig=img_directory.replace("\ ", " ")
for fname in dirList:

    fake=fname.replace(" ", "_")

    fake_dir=img_directory_orig.replace(" ", "_")
    fake_dir1=fake_dir.replace("/", "_")
    if os.path.isfile(server_directory+"temp/"+"m_"+fake_dir1+"_"+fake_name):
        print "Exists!"
        if (fname<>"Thumbs.db"):
            real=fname.replace(" ", '\ ')
            real1=real.replace("(", '\(')
            real_name=real1.replace(")", '\)')
            command_string= 'cp '+server_directory+"databackup/photos/"+img_directory.replace(" ","\ ")+"/"+real_name+" "+server_directory+"temp/m_"+fake_dir1+"_"+fake_name
            second_command_string = 'mogrify -resize 1024 '+server_directory+"temp/m_"+fake_dir1+"_"+fake_name

Take a look at the "find" command and also TEST when used with "if [ ] then"
For example the following find command will generate a list of files starting in the directory name provided as the first parameter and include the backslash to escape characters in the name:

find $1 -type f -ls | awk '{ print $11 }'
for x in `find . -type f -ls | awk '{ print $11 }'`
if [ -s $x ] then
echo "Found file $x "

from a command line do:
man find
man if
man test

for some help.