• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Putting a list of files in a particular order
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Putting a list of files in a particular order


  • Subject: Re: Putting a list of files in a particular order
  • From: Jay Louvion <email@hidden>
  • Date: Wed, 03 May 2006 11:15:38 +0200
  • Thread-topic: Putting a list of files in a particular order

Title: Re: Putting a list of files in a particular order
On 3.5.2006 4:26, entity "Malcolm Fitzgerald" <email@hidden> spake thus:

>
> I've got to ask why the copy sequence matters?
>
> malcolm

Oh, and while I’m at it, there are two reasons why I wished to develop an AS solution rather than continue using the shell:

The shell causes the focus to jump during the copying operation, making it virtually impossible to do another task at the same time on the machine.

The shell can be invoked and opened more than once (by mistake), causing some pretty annoying conflicts between the processes (including incomplete copying, which is desastrous on jpegs and on our reputation). An AS app will only become frontmost if clicked again.



For information purposes, here is the content of the shells:

Achronological:

processFile() {
   echo "processing file $1"
   if [[ "$( GetFileInfo -aL "$1" )" == "0" ]]
   then
       base=$(basename "$1")

       if [[ -e "$photoIn/$base" ]]
       then
           echo "Skipped: target already exists"
       else
           echo "Copying $1"
           if cp -p "$1" "$temp/$base"
           then
               echo "... done"
               mv "$temp/$base" "$photoIn/$base"
               SetFile -a L "$1"
           else
               echo "... failed"
               rm -f "$temp/$base"
           fi
       fi
       return 0
   fi
   return 1
}

processFiles() {
   result=0
   somethingdone=0
   while read filename
   do
       if processFile "$filename"
       then
           result=1
       fi
       somethingdone=1
   done
   if (( $result == 0 && $somethingdone == 1 ))
   then
       diskutil unmount /Volumes/*/DCIM
   fi
}

photoIn="/Users/jay/PhotoIn"
if [[ -n "$1" ]]
then
   photoIn="$1"
fi
temp="/Users/jay/PhotoTemp"
if [[ -n "$2" ]]
then
   temp="$2"
fi

while true
do
   find /Volumes/*/DCIM -name '*.[jJ][pP][gG]' -print0 | /usr/bin/xargs -0 /bin/ls -t | processFiles
   sleep 2
done


Chronological:

processFile() {
   echo "processing file $1"
   if [[ "$( GetFileInfo -aL "$1" )" == "0" ]]
   then
       base=$(basename "$1")

       if [[ -e "$photoIn/$base" ]]
       then
           echo "Skipped: target already exists"
       else
           echo "Copying $1"
           if cp -p "$1" "$temp/$base"
           then
               echo "... done"
               mv "$temp/$base" "$photoIn/$base"
               SetFile -a L "$1"
           else
               echo "... failed"
               rm -f "$temp/$base"
           fi
       fi
       return 0
   fi
   return 1
}

processFiles() {
   result=0
   somethingdone=0
   while read filename
   do
       if processFile "$filename"
       then
           result=1
       fi
       somethingdone=1
   done
   if (( $result == 0 && $somethingdone == 1 ))
   then
       diskutil unmount /Volumes/*/DCIM
       osascript -e 'say "Process complete. Card unmounted"'
   fi
}

photoIn="/Users/jay/PhotoIn"
if [[ -n "$1" ]]
then
   photoIn="$1"
fi
temp="/Users/jay/PhotoTemp"
if [[ -n "$2" ]]
then
   temp="$2"
fi

while true
do
   find /Volumes/*/DCIM -name '*.[jJ][pP][gG]'| processFiles
   sleep 2
done





Cordialement,

j.

Jay Louvion
Studio Casagrande
3, rue Müller-Brun
1208 Geneva

T+4122 840 3272
F+4122 840 3271

skypeme:
jaylouvion

www.studiocasagrande.com


P Please consider the environment before printing this email.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Putting a list of files in a particular order
      • From: Björn Lundin <email@hidden>
    • Re: Putting a list of files in a particular order
      • From: Michael Schmidt <email@hidden>
References: 
 >Re: Putting a list of files in a particular order (From: Malcolm Fitzgerald <email@hidden>)

  • Prev by Date: Re: Putting a list of files in a particular order
  • Next by Date: Re: Putting a list of files in a particular order
  • Previous by thread: Re: Putting a list of files in a particular order
  • Next by thread: Re: Putting a list of files in a particular order
  • Index(es):
    • Date
    • Thread