[ale] Scripting question

Joe Steele joe at madewell.com
Thu Apr 21 18:55:11 EDT 2005


#!/bin/bash
srcdir="xxx"
dstdir="yyy"
cd "$srcdir"
cnt=10000
#This next line may need refining, depending on what's in "xxx"
#and the order you want to processs the files in:
for i in *; do
   rpt=0
   while [ $rpt -lt 4 ]; do
      cp "$i" "$dstdir/aea.${cnt#1}.ppm"
      rpt=$[ $rpt + 1 ]
      cnt=$[ $cnt + 1 ]
   done
done

-----Original Message-----
From:	Dow Hurst [SMTP:Dow.Hurst at mindspring.com]
Sent:	Thursday, April 21, 2005 6:02 PM
To:	Atlanta Linux Enthusiasts
Subject:	[ale] Scripting question

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

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale



More information about the Ale mailing list