• 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: Removable Disks (wrapping code)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removable Disks (wrapping code)


  • Subject: Re: Removable Disks (wrapping code)
  • From: email@hidden
  • Date: Mon, 10 Nov 2003 16:42:53 -0500
  • Priority: normal

Hi Christopher,

>on removableVolume(pics)
> set desktopPath to (path to desktop) as string
>Is (pics) a container for removableVolume? I haven't run
across syntax
>like this and am guessing...

(pics) is actually a parameter for that subroutine. In the
earlier code that said:

-----------------
tell application "Finder"
tell (disks whose ejectable is true)
if it exists then my removableVolume(it's name)
end tell
end tell
-----------------

you'll notice that the parameter given to 'removableVolumne'
is (it's name). (it's name) refers to the name of each disk
whose ejectable is true (for example, if I had loaded a CD
called 'CD1' and a firewire named 'Backup Files', then (it's
name) would be a list of {"CD1","Backup Files"}. So, I'm
calling the 'removableVolume' subroutine, and I'm giving it
a parameter of (it's name) and when you go to the actual
'removableVolume' subroutine I'm using (pics) for the
parameter name that holds the list of items of (it's name).
Hope I haven't confused you, but let me know if you have
further questions.


> repeat with x in pics
> with timeout of 600 seconds
> try
> move disk x's items to folder (desktopPath &
newFolderName)
>I'm not clear on "repeat with x in pics" nor am I with
"move disk x's
>items...." I understand that this portion of the code
copies from
>removable device to folder on the desktop but beyond that
I'm unsure.

'repeat with x in pics' is simply going through the list of
'disk names'. For example, if (pics) was {"CD1","Backup
Files"} then this repeat loop would go through 2 times. The
first time when the loop hits 'move disk x's items to folder
(desktopPath & newFolderName)' it's really saying 'move disk
"CD1"'s items to folder (desktopPath & newFolderName)'. 'x'
is holding the value of the current item in the list. The
second time through it would be 'move disk "Backup File"'s
items to folder (desktopPath & newFolderName)'. Again, let
me know if you have any further questions.


>The problem is that the folder 100CANON isn't always named
as such. It
>could be 101CANON, 102CANON, etc. There is another folder
that is
>consistently named on the same level as 100CANON-
"CANONMSC".

I'm a bit confused here. Do you have 2 ejectable disks with
the same name?

By the way, I did run into a problem when testing this
script on a machine that has 3 partitions. For some reason,
even though I was asking for 'ejectable' disks, it tried to
pull data from my 'Macintosh HD' and other partitions and
then it tried to eject them. Anyone know why it would think
partitions are ejectable?

>How would I consistently point this script to these image
files? Better
>yet, is there a way to search this volume for JPEGs and
TIFFs? If so,
>this would allow the script to handle any removable volume
with image
>files.

I've added some code below that should grab just JPEGs and
TIFFs for you. It attempts to pull them from every folder
on the disk. I haven't done much testing with this, so
you'll want to be sure to test this thoroughly to make sure
it's working correctly. I've also stuck a blank line
between each line of code, so in case it wraps in this email
you'll be able to fix the wrapping text.

Jay

---------------



on idle {}

tell application "Finder"

tell (disks whose ejectable is true)

if it exists then my removableVolume(it's name)

end tell

end tell

return 5

end idle

on removableVolume(pics)

set desktopPath to (path to desktop) as string

repeat with x in {{January, "01"}, {February, "02"}, {March,
"03"}, {April, "04"}, {May, "05"}, {June, "06"}, {July,
"07"}, {August, "08"}, {September, "09"}, {October, "10"},
{November, "11"}, {December, "12"}}

tell (current date) to if it's month is x's item 1 then

set newFolderName to (year & "-" & x's item 2 & "-" & ("0" &
day)'s text -2 thru -1) as string

exit repeat

end if

end repeat

tell application "Finder"

if not (exists (folder (desktopPath & newFolderName))) then

make new folder at folder desktopPath with properties
{name:newFolderName}

end if

repeat with x in pics

with timeout of 600 seconds

try

move (disk x's entire contents's files whose file type is in
{"TIFF", "JPEG"}) to folder (desktopPath & newFolderName)

on error the error_message number the error_number

display dialog "Error: " & the error_number & ". " & the
error_message buttons {"OK"} default button 1

end try

end timeout

eject disk x

end repeat

end tell

end removableVolume
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Panther: AppleScript 1.9.2 Release Notes
  • Next by Date: Re: how to access the folder/directory popup button in the nav dialog
  • Previous by thread: Re: Removable Disks (wrapping code)
  • Next by thread: Re: Removable Disks (wrapping code)
  • Index(es):
    • Date
    • Thread