[ale] Scripting question

Dow Hurst Dow.Hurst at mindspring.com
Thu Apr 21 18:10:34 EDT 2005


I have a directory with 148 ppm image files named like so:
aea_h6_2-4ns_v2.0037.ppm

I want to copy each file four times incrementing the name for each of 
the four copies.  So the file aea_h6_2-4ns_v2.0000.ppm is copied and 
renamed to the destination directory as:
aea.0000.ppm
aea.0001.ppm
aea.0002.ppm
aea.0003.ppm

then I want to increment to the next file in the source directory and 
start again.  So aea_h6_2-4ns_v2.0001.ppm becomes in the destination 
directory:
aea.0004.ppm
aea.0005.ppm
aea.0006.ppm
aea.0007.ppm

I have this bit of code I used for a similar purpose but different 
enough that I am having trouble rewriting it to do what I want.  I'm 
sure perl would be perfect for this but I have simple shell code:
#!/bin/sh
#############################################################
# Ex. ./select.sh '0003' '0000'  'aea_h6_2-4ns_v2.0001.ppm' 
/SOURCEPATH/FILE /DEST_PATH/FILE
# Written by Dow Hurst 07-01-2002
#############################################################
j=$1
i=$2
inputfile="$3 $3 $3 $3"
CWD=`pwd`
SOURCE=$4
DEST=$5
################
echo "Changing to SOURCE directory"
cd $SOURCE
for out in $inputfile
    do  abc=aea.$i.ppm
        echo $out $abc
        cp -p $SOURCE/$out $DEST/$abc
    if [ $i = $j ]
       then break
    fi
       i=`expr $i + 1`
done
echo "Changing back to CWD directory"
cd $CWD
exit

One problem I found is that the 0000 doesn't really work with this 
code.  You have to use 1000 instead so the file names would go from:
aea_h6_2-4ns_v2.0000.ppm
aea.1000.ppm

The purpose behind this is to feed the files to ppmtompeg to create a 
movie.  VMD does this but won't repeat a image frame four times.  
MainActor will do a slowmo effect but the output is not clear and 
sharp.  Single frames from the molecular dynamics trajectory end up with 
molecules wiggling too fast.  VMD has written out here every fourth 
frame from the trajectory and I just want to repeat the frame four 
times.  Hope this makes sense!  Thanks for the scripting help,
Dow



More information about the Ale mailing list