An Array of Variables?

Anyone knwo how I can build an array of variables? As you can see I have INBOXFIND and INBOXMOVE but when I try to call them in my find it is giving me a directory not found error. The paths are correct to. Just not sure what I am doing wrong. I have never called an array of variables before.

SERVER72IN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/72/In/
SERVER72OUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/72/In/
LOCAL72IN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/72/In/
LOCAL72OUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/72/In/

SERVER2400IN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/2400/In/
SERVER2400OUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/2400/In/
LOCAL2400IN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/2400/In/
LOCAL2400OUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/2400/In/

SERVERADSENDIN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/Adsend/In/
SERVERADSENDOUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Server/Adsend/In/
LOCALADSENDIN=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/Adsend/In/
LOCALADSENDOUT=/Volumes/Macintosh\ HD/Users/distillers/Desktop/Local/Adsend/In/

LOGPATH=~/Desktop/

INBOXFIND=($SERVER72IN, SERVER2400IN, SERVERADSENDIN)
INBOXMOVE=($LOCAL72IN, LOCAL2400IN, LOCALADSENDIN)

######################################################
####################Start Shell#######################
for i in “${INBOXFIND[@]}”
do
find $i -type f ! -name “." | while read FN
do
# Check to see if file has finished copying…
X=lsof "$FN" | wc -l
if [ $X == 0 ]
#if [ $X -le 2 ]
then
case $1= in
[ $i == “${INBOXFIND[0]}” ]) mv “$FN” “${INBOXMOVE[0]}”
;;
[ $i == “${INBOXFIND[1]}” ]) mv “$FN” “${INBOXMOVE[1]}”
;;
[ $i == “${INBOXFIND[2]}” ]) mv “$FN” “${INBOXMOVE[2]}”
;;
esac
#if [ $? == 0 ]
#then
#printf "${FN##
/}”\tmoved to zIn_Progress…\tdate +%b\ %d\ %y\ %H\:%M\:%S\n" >>$LOGPATH
#fi
else
printf “${FN##*/}”\tis still copying…not moved to zIn_Progress yet…\tdate +%b\ %d\ %y\ %H\:%M\:%S\n" >>$LOGPATH
fi
done
done

Thanks!!!

Hi there…

first of all, I think there’s a parenthesis imbalance in the script you posted - but I guess this isn’t in the script you’re using?

[ $i == “${INBOXFIND[0]}” ]) mv “$FN” “${INBOXMOVE[0]}”

The ‘)’ after ‘…FIND[0]}" ]’ looks somewhat superfluous to me :slight_smile:


Also, IIRC in bash one declares arrays w/o commas, and some of the '$'s seem to be MIA:

INBOXFIND=($SERVER72IN, SERVER2400IN, SERVERADSENDIN)

…should be…

INBOXFIND=($SERVER72IN $SERVER2400IN $SERVERADSENDIN)


Didn’t have the time to test these findings, sorry, but perhaps this helps?

Regards,
danB

Model: iBook (g3/800, 14,1")
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)