OK script finished tested and working:

#!/bin/bash
rm background-2.xml
echo "<background>" >> background-2.xml
echo "  <starttime>" >> background-2.xml
echo "    <year>2009</year>" >> background-2.xml
echo "    <month>08</month>" >> background-2.xml
echo "    <day>04</day>" >> background-2.xml
echo "    <hour>00</hour>" >> background-2.xml
echo "    <minute>00</minute>" >> background-2.xml
echo "    <second>00</second>" >> background-2.xml
echo "  </starttime>" >> background-2.xml
echo "<!-- This animation will start at midnight. -->" >> background-2.xml

#counter variable
x=1

for file in *.jpg

do
        if [ $x -eq 1 ]
then
FE='<to>/usr/share/backgrounds/testdir/'
FE="${FE}$file"
FE="${FE}</to>"
fi
 if [ $x -gt 1 ]
then
FT='<to>/usr/share/backgrounds/testdir/'
FT="${FT}$file"
FT="${FT}</to>"
echo $FT >> background-2.xml
echo "</transition>" >> background-2.xml
 fi
 echo "  <static>" >> background-2.xml
echo "    <duration>1795.0</duration>" >> background-2.xml
 FS="   <file>/usr/share/backgrounds/testdir/"
FS="${FS}$file"
FS="${FS}</file>"
 FR="   <from>/usr/share/backgrounds/testdir/"
FR="${FR}$file"
FR="${FR}</from>"
 FT="   <to>/usr/share/backgrounds/testdir/"
FT="${FT}$file"
FT="${FT}</to>"
 echo $FS >> background-2.xml
echo "  </static>" >> background-2.xml
echo "  <transition>" >> background-2.xml
echo "    <duration>5.0</duration>" >> background-2.xml
echo $FR >> background-2.xml
     #ls "$file"  # Lists all files in $PWD (current directory).

    x=$(( $x + 1 ))

    #echo $x

done

echo $FE >> background-2.xml
echo "</transition>" >> background-2.xml
echo "</background>" >> background-2.xml

exit 0

Change "/usr/share/backgrounds/testdir/" to match your directory with search
& replace.

Will tart it up with zenity later.
-- 
ubuntu-uk@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/

Reply via email to