Applescript to create butto

Hello All,
Newb here. Just learning about applescript. Here's what I'm trying to learn.
In iDVD, I was wondering if it would be possible to write a script that would allow iDVD to create a link or button in the dvd menu to access the DVD-ROM Contents folder. Or even automatically launch a projector file. Possible?
Thanks!

I don't think you can do this.
Because DVD disks conform to a standard (so they can play in any DVD player) there are limited technologies you can employ. Since no DVD player in the world supports AppleScript, you can't attach an AppleScript to a button and have it work.
That said, you can create buttons in iDVD menus that link to specific media on the disk, but not at a filesystem level (e.g. you can jump to a chapter or specific video footage on disk, but not open a file).

Similar Messages

  • Using AppleScript to create a text file, based on an OCR'd file's content

    Hey guys, I've got an interesting situation.
    I was wondering if there would be anyway to use something like AppleScript (or the like) to create a text document and fill it with information based on what is found in an already OCR'd file?
    For example: I have a paycheck stub. The stub contains the words "Gross Pay" and the value "$xxxx.xx" on one line. Using Hazel to identify paychecks (based upon filenames), could I then use something like AppleScript, to create a new text file, and then pull the text from the line that contains the word's "Gross Pay" and insert it into the text file's next line?
    Ex:
    March 26,2012      
    Gross Pay                   $xxxx.xx
    April 6,2012
    Gross Pay                   $xxxx.xx
    Kind of how TurboTax's iPhone app pulls text from an image, then uses the values to insert it into the app's appropriate fields?
    I know this may be a lot to ask, but any help is appreciated. Thanks!

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Applescript to create a New Network

    Hi all!
    I'd like to build an applescript to create a New Network on Mac OS 10.6.
    The script should run on a computer without a screen, and I will interact with the Mac through a VNC application on an Ipad, which I already have. So I need to know that every time the IP address of the private network will be the same.
    I'm very new to Applescript so i was wondering if you could give me some tip on how to start, I've been trying with no success since yesterday but I know it can't be that difficult!
    thanks!

    OK, that helps a little, but not a lot... I'm still not getting it - or maybe you're not...?
    Is the machine local to the iPad - i.e. are they on the same LAN?
    If the machines are remote then creating a new wireless network isn't going to help since you'd also need to configure your router for port forwarding, etc.
    If the machines are on the same LAN, though, the iPad should be able to connect directly - without any internet exposure - so you don't need to create a new network. You should be able to just configure the wireless network with a specific, known IP address and connect to that... unless you don't have a base station...?

  • Applescript for creating job folders

    having trouble with an applescript. I'm trying to create an applescript that will create a job folder for me with job number and job name in which I can include folders and subfolders.
    I found this script by searching google and it's pretty much what I need (thank you to who ever might have created it). I altered the folder names to what I need, and it seems to work for the most part but throws an error at the end that says : Finder got an error: Can't make "drive:path" into type item
    however it still makes everything i need. I would just like to get rid of the error.
    the script editor highlights the line of text that's having issues for me, but since i barely knew what I was doing in the first place I don't know how or what to change.
    if someone could help me that would be great. here is the code.
    set thepath to {"drive:path"}
    set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
    set incomingDate to (current date)
    set numYear to year of incomingDate as number
    set textYear to text -2 through -1 of (numYear as string)
    set JobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
    set JobNumName to JobNum & "_" & JobName
    set newsublist to {{"Builds", {"versions"}}, {"Links"}, {"Fonts"}, {"Proofs"}}
    tell application "Finder"
    set baseFolder to make new folder with properties {name:JobNumName}
    repeat with i from 1 to count newsublist
    try
    set {tier2, t2Subs} to {item 1, item 2's items} of item i of newsublist
    set tier2Folder to make new folder at baseFolder with properties {name:(tier2)}
    repeat with tier3 in t2Subs
    make new folder at tier2Folder with properties {name:(tier3)}
    end repeat
    on error
    make new folder at baseFolder with properties {name:(item 1 of item i of newsublist)}
    end try
    end repeat
    activate
    open thepath
    end tell

    There are a few differences with Leopard that still get me from time to time. Tiger's AppleScript doesn't like path to desktop, so instead use the statement:
    set ThePath to (get path to desktop folder)
    The other thing I hadn't noticed before is if there is an error, the script just stops instead of throwing up a dialog. If you are doing something like using an illegal file name or trying to create a folder in a location that you don't have permissions, then unless the MakeFolderStructure statement is in a try statement it will fail silently. Adding an error display will at least tell you if there is an error, so a script that works in Tiger (as well as Leopard) is:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    -- make a folder structure at the currently selected Finder item
    tell application "Finder" to try -- get the current selection
    set ThePath to the first item of (get selection)
    if the last character of (ThePath as text) is not ":" then -- a file
    set ThePath to the container of ThePath
    end if
    on error -- default to the desktop
    set ThePath to (get path to desktop folder)
    end try
    set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
    set textYear to text -2 through -1 of ((current date)'s year as text)
    set JobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
    set JobNumName to JobNum & "_" & JobName
    try
    MakeFolderStructure out of {JobNumName, {"Builds", {"versions"}, "Links", "Fonts", "Proofs"}} at ThePath
    on error ErrorMessage number ErrorNumber -- oops
    activate me
    display alert "Error " & ErrorNumber message ErrorMessage
    end try
    to MakeFolderStructure out of SomeItem at SomeFolder
    make the folder structure defined in SomeItem at SomeFolder
    SomeList defines the structure:
    nested list items create folders in the previous text item - {"A", {"B", {"C"}}} = /A/B/C
    empty text items will create untitled folders
    parameters - SomeItem [mixed]: the folder structure
    SomeFolder [alias]: the destination folder
    returns nothing
    set ParentFolder to SomeFolder
    if class of SomeItem is list then
    repeat with AnItem in SomeItem
    if class of AnItem is list then -- add subfolder(s)
    MakeFolderStructure out of AnItem at SomeFolder
    else -- add a new child folder at the current parent
    tell application "Finder" to make new folder at ParentFolder with properties {name:AnItem}
    set SomeFolder to the result as alias
    end if
    end repeat
    else -- add a new (potential) parent folder
    tell application "Finder" to make new folder at SomeFolder with properties {name:AnItem}
    set ParentFolder to the result as alias
    end if
    end MakeFolderStructure</pre>

  • Applescript to create an address list text file

    I need a script to look through a selected group and get the first and name, and the 'street address' of the address whose label is 'primary'.  I want to save this list as a CSV file, with a comma seperating the name from the street, and a new line/carriage return after each entry.  I've done a little with applescript, but I can't quite figure this one out.  Here's what I've got so far:
    tell application "Address Book"
              set _groups to name of every group
              choose from list _groups with title "Create Address List" with prompt "Select an Address Book Group"
              set theirChoice to result as string
              set theContacts to (people in group theirChoice)
              repeat with thePerson in theContacts
      display dialog theirChoice
      --get addresses & names here
              end repeat
    end tell
    Thanks for the help.

    After more searching, I found this which will take care of adding the text to the text file.  I just need to figure out how to get the streetAdress from the Address whose label is 'Primary'
    set newText to "Name, streetAdress"
    --newText will be the current contact's name/address info, and the next line adds it to the text file
    do shell script "echo " & quoted form of newText & " >> ~/Desktop/PlainText.csv"

  • Use applescript to create itunes smart playlists

    hi
    is the subject possible?
    my setup uses an intricate system of smart playlists building other smart playlists. when i add a new "theme", as i call it, like "party", "chart", "sad", "happy", etc, i dont want to have to go back through and create dozens of smart playlists each time... that is a job for my friend, applescript!
    regards
    jingo_man

    I am also interested in an answer on this. I'm not an AppleScript guru but I'm learning. My goal is to create a Smart Playlist with two criteria -- one is that the tracks exist in a specific other Smart Playlist and the other is that the track's play count is less than the average play count of all tracks in the other playlist.
    I have already managed to use AppleScript to find the average play count of all tracks in a selected Smart Playlist, I just don't yet know how to use that to automatically generate a second Smart Playlist.

  • LF applescript to create users by dscl NOT dsimport

    Good evening
    I do a lot of my maintenance by applescripts that are run by mail rule. Easy applescripts
    Since dsimport files seem way too complicated to be provided by mail (there have to be UNIX breaks and so on) I am asking for your help.
    I would like to have an applescript that filters the inbox for a string like "Create User Account: " and uses the rest of the subject as parameters to create the respective user accounts.
    A full mail subject could look like this: "Create User Account: mleuenberger,Moritz,Leuenberger,6(sRpq4"
    Henceforth the applescript would run
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger"
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger"
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger UserShell /bin/bash"
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger RealName "Moritz Leuenberger""
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger UniqueID "XXXX""
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger PrimaryGroupID 80"
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -create /Users/mleuenberger NFSHomeDirectory /Users/mleuenberger"
    do shell script "dscl -u admin -P MyPW /LDAPv3/127.0.0.1 -passwd /Users/mleuenberger 6(sRpq4"
    Appending the seperate responses to a variable would be luxury, so I could have it send them by mail as my other applescripts respond.
    I don't know if setting a UniqueID is required (hopefully not) because it had to be randomly generated. I have no idea how to do this in applescript.
    I am very thankful for any help.
    Greetings from snowy switzerland

    It would certainly run the "-create /Users/mleuenberger" command only once.

  • Applescript to create subfolders in a new folder

    Hi there,
    I have a bit of programming experience, but none with Applescript.  I've tried to see if I can find someone else looking to do something similar, but so far haven't been able to.
    Anyways!  I am wanting to create an AppleScript --> Folder Action that will watch a folder, say, folder "ABC".  Anytime a new folder is created within "ABC", let's call it "XYZ", I want the script to create a series of predetermined folders within "XYZ".  Sounds simple enough, right?
    Any help would be greatly appreciated.  Thanks!
    Justin

    Ok, so the "More Like This" thing on the right did a better job of searching than I did...
    I managed to find something similar enough to what I was looking for.  Here's what I came up with:
    property folder_names : {"Folder One", "Folder Two", "Folder Three"}
    set thepath to "Macintosh HD:Users:justin:Desktop:test"
    set project_name to text returned of (display dialog "Project code?" default answer "")
    tell application "Finder"
              set main_folder to (make new folder at thepath with properties {name:project_name})
              repeat with this_name in folder_names
      make new folder at main_folder with properties {name:this_name}
              end repeat
              set current view of container window of main_folder to list view
    end tell
    You would think that after how ever many years of searching I would have been able to find this earlier!

  • Mail; Using applescript to create an auto-reply with attachments

    I know nothing about applescript and so have no clue how to do this. I tried googling a script but couldn't find one. I also saw similar posts on this topic, but couldn't find scripts.
    I am looking for a simple applescript to go into the Mail app rules to reply with an email message with an image attachment. does anyone know where I can find that script? again, I know nothing about applescript, so I cant do it myself, so details would be nice.
    thanks!

    ok no one replied. now i am wondering, how can i get automator to maybe add an attachment to a current outgoing message. i saw an option for that in automator, but it only works if you have automator create a new email message which i dont want. im using mailtemplate to reply to email messages and quickeysx too, so what i need is to add an automator script to just add an attachement (or 2) to the current outgoing email message. or maybe there is an apple script to add attachment to the mail message on screen? any help would be great thanks

  • Automator/Applescript to Create New Pages Doc in Selected Folder

    When working in Finder I'd like to be able to create a folder, and then (still within Finder) create a number of Pages documents inside that folder. This would help in organizing complex projects, and would be preferable to creating the documents (from the bottom up) in Pages and then laboriously assigning each document to a different folder.
    I've tried various solutions in Automator and Applescript but nothing has worked.
    For example:
    try
    tell application "finder" to set myFolder to (folder of the front window)
    on error -- no open folder windows
    set myFolder to path to desktop folder
    end try
    tell application "Pages"
    activate
    set myDocument to make new document with properties {path:myFolder}
    end tell
    But this gets an error "Can't make [the selected folder] of application "Finder" into the expected type. (-1700).
    In automator, I've tried to do the following:
    1. Get Selected Finder Items (which will be the folder I want)
    2. (Create new variable "path" and drag onto 1., which creates "Get Value of variable)
    3. (ignoring input) Get Specified Finder Item (specifying a blank Pages document)
    4. (accepting input) Copy Finder Item to variable "path"
    The problem with this is that step 2 returns both the desired folder AND the desktop. The result of the entire process, moreover, is that the blank Pages file is created (or rather copied to) the desktop ONLY, and not to the desired folder.
    Anyway, I hope someone can help me with this. It would really speed up my organizing process.
    Wes

    Taking care of true window's properties is often useful
    on run
    try
    tell application "Finder" to set myFolder to (target of the front window) as alias
    on error -- no open folder windows
    set myFolder to path to desktop folder
    end try
    set myNewDoc to my makeNewIworkDoc("Pages", "myNewDocument" & my dateTimeStamp() & ".pages", myFolder as text)
    end run
    --=====
    Creates a new iWork document from Blank.template,
    saves it and returns its pathname.
    example:
    set myNewDoc to my makeNewIworkDoc(theApp, docName, folderPath)
    on makeNewIworkDoc(a, n, d)
    local t, c
    if a is "Pages" then
    set t to ((path to applications folder as text) & "iWork '09:Pages.app:Contents:Resources:Templates:Blank.template:") as alias
    else if a is "Numbers" then
    set t to ((path to applications folder as text) & "iWork '09:Numbers.app:Contents:Resources:Templates:Blank.nmbtemplate:") as alias
    else
    if my parleAnglais(theApp) then
    error "The application “" & a & "“ is not accepted !"
    else
    error "l’application « " & a & " » n’est pas gérée !"
    end if
    end if
    set f to d & n
    tell application a
    set c to count of documents
    open t
    repeat
    if (count of documents) > c then
    exit repeat
    else
    delay 0.1
    end if
    end repeat
    save document 1 in file f
    end tell -- theApp
    return f as alias
    end makeNewIworkDoc
    --=====
    on parleAnglais()
    local z
    try
    tell application "Numbers" to set z to localized string "Cancel"
    on error
    set z to "Cancel"
    end try
    return (z is not "Annuler")
    end parleAnglais
    --=====
    on dateTimeStamp()
    return (do shell script "date +P%Y%m%d-%H%M%S")
    end dateTimeStamp
    --=====
    Yvan KOENIG (VALLAURIS, France) vendredi 4 septembre 2009 20:51:02

  • Applescript for creating a network at start-up

    Everytime I start up my mac the network I created is gone and I have to create a new one.
    So I want to create an applescript that I can use as start-up item (application)
    I found an applescript on the net but that one isn't working on my mac. So I changed it a little.
    It works for "turn airport on" (instead of "Open Network Preferences...")
    But "Open Network Preferences..." is below a grey line.
    What am I doing wrong?
    property CreateMenuName : "Create Network…"
    property NetworkName : "Net"
    property NetworkPassword : "paswd"
    tell application "System Events"
              tell process "SystemUIServer"
      tell menu bar 1
      set menu_extras to value of attribute "AXDescription" of menu bar items
      repeat with the_menu from 1 to the count of menu_extras
                                            if item the_menu of menu_extras is "Airport Menu Extra" then exit repeat
      end repeat
      tell menu bar item the_menu
                                            perform action "AXPress"
                                            delay 0.2
                                            perform action "AXPress" of menu item "Open Network Preferences..." of menu 1
      end tell
      end tell
      repeat until exists window 1
                                  delay 0.5
      end repeat
      tell window 1
      click checkbox 1
      click pop up button 2
      click menu item 2 of menu 2 of pop up button 2
      click checkbox 1
      set value of text field 2 to NetworkPassword
      set value of text field 3 to NetworkPassword
      set value of text field 1 to NetworkName
      click button 1
      end tell
      end tell
    end tell

    Well in another discussion I got the answer of keeping your self created network when closing and starting up your mac. The created network will be remembered in System Preferences/Sharing/Internet Sharing/Airport options.
    But somehow it needs to be activated. And you can do that by un-clicking "Internet Sharing" and clicking it again and click "Start" So with thanks to BDAqua I came to the following Automator workflow to be saved as an application which you can put in System Preferences/Accounts/ login-items.
    on run {input, parameters}
    tell application "System Preferences"
    activate
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 2
    tell window "Sharing"
    click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1
    delay 1
    if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
    click button "Turn AirPort On" of sheet 1
    delay 1
    end if
    click button "Start" of sheet 1
    end if
    end tell
    end tell
    end tell
    tell application "System Preferences"
    activate
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 2
    tell window "Sharing"
    click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1
    delay 1
    if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
    click button "Turn AirPort On" of sheet 1
    delay 1
    end if
    click button "Start" of sheet 1
    end if
    end tell
         end tell
    end tell
    tell application "System Preferences"
    quit
    end tell
    return input
    end run

  • Applescript to create mail is not working correct in Lion

    Hi all
    When I run this applescript in Lion to send a mail with Apple Mail
    tell application "Mail"
              set theNewMessage to make new outgoing message with properties {subject:"Subject text", content:"Content text", visible:false}
              tell theNewMessage
      make new to recipient at end of to recipients with properties {address:"[email protected]"}
      send
              end tell
    end tell
    It send the mail just fine
    Go to Mail and you see it in send items
    Now try to close Mail with cmd q and you notice that the mail popup ready to send a second time.
    If you hit the send button it will be mailed again and when you use cmd q now it will close Mail.
    As far as I know this will not happen in Snow
    If it is possible I like to know I I am correct that it is working OK in Snow and that Lion is the problem
    Thanks for testing
    Regards, Ron de Bruin

    I think setting visible always to true will be the solution, but I can't test in Snow anymore.

  • Applescript to create alphabetical folders....

    I have searched everywhere and can't figure out how to do this. I want to create a list of folders with the letters of the alphabet as the name. Example: A, B, C, etc. - for filing purposes. Anybody have any suggestions?

    Here's a way to accomplish the same thing type of thing without using the Finder.
    <pre style="margin: 0px; padding: 5px; border: 2px dotted green; width: 600px;
    height: 100px; color: #ffffff; background-color: #000000; overflow: auto; font-family: Verdana, Monaco, monospace; font-weight: 900; font-size: 12px;"
    title="Copy this text and paste it into your Script Editor application.">set theFolder to POSIX path of (choose folder)
    repeat with x from 65 to 90
    do shell script "mkdir " & quoted form of (theFolder & (ASCII character x))
    end repeat</pre>
    Hope this helps...

  • Combine two applescripts to create backup extravaganza script

    Dear all,
    I'm a complete newbie to applescripts and my new external backup HDD made it necessary for me to work with it. As it is quite noisy I wanted to write a script that mounts the disk if it is unmounted, runs the backup and then ejects the backup disk again (Code A). So far so good. In order to eject the disk after backup has finished I found a piece of code to check if a process is still running (Code B). It returns 1 if the backup process (backupd) is still alive and 0 if it is finished.
    I am struggling now with combining those two pieces. I would like code B to keep checking after the backup has started if backupd is still running and if it is done go to the next step and eject the disk.
    I just can't get code B running in code A and also the needed loop confuses me a bit. Any help is really greatly appreciated!! I can't imagine it's that tricky just too much for my imagination Thanks for helping me restoring peace and quietness
    Code A:
    set myVolumeLabel to "Time Machine"
    tell application "Finder"
      set diskDev to do shell script "diskutil list | grep \"" & myVolumeLabel & "\" | grep -o 'disk[0-9]*' "
      if not (disk myVolumeLabel exists) then
      do shell script "diskutil mountDisk " & diskDev
      do shell script "/System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper >/dev/null 2>&1 &"
    (* Checking if the backupd process is still running should go here I suppose.*)           
      else
      do shell script "diskutil eject /Volumes/'Time Machine' " & diskDev
      end if
    end tell
    Code B
    on check_process(marker)
      set the_processes to (do shell script "ps -A")
      return (the_processes contains marker)
    end check_process
    if check_process("/backupd") then
      set x to "1"
    else
      set x to "0"
    end if
    ---display dialog x buttons {"OK"} default button 1

    You're making it too hard on yourself
    The default AppleScript action is to wait for each command to finish, you've gone out of your way to return control to your script, hence the need for a separate process check.
    The ' > /dev/null 2>&1 &" at the end of your 'do shell script' that runs the backup returns control to your script immediately. If you eliminate that part then AppleScript will pause, waiting for the command to finish before continuing with your script.
    If, for some reason, you want to return control to your script then just add something like:
    set isBackingUp to true
    repeat until isBackingUp is false
              checkProcess("backupd-helper")
    end repeat
    in your code where you've identified the check should go. This will repeatedly run the checkProcess() handler until it returns false (indicating the process is no longer running), as which point you can unmount your disk.

  • Using AppleScript to create folders and place files in them

    Hi guys,
    I've been reading through the forum for the better part of the last 6 hours wracking my brain trying to figure out how to accomplish what I'm trying to do. I've been playing around with Automator and also trying to decipher some Apple Script samples that were posted on here, but I'm really having no luck at all. I'm sure you've all been there where you feel like you're on an endless search to solve a problem and it feels like there's no hope. I've tried every single possible thing I can and I'm getting close, but it's never quite right.
    Here's what I'm trying to do, and hopefully some kind soul will help me out. I'm deseperately trying to figure this out, and any help at all would be GREATLY appreciated!
    I have a bunch of PDF files that I scan, in the hundreds. After I've scanned them I'm left with something like this:
    1234567_Elephant.pdf
    1234567_Duck.pdf
    1234567_Cat.pdf
    1234567_Cat_01.pdf
    1234567_Dog.pdf
    3431233_Elephant.pdf
    3431233_Dog.pdf
    3431233_Dog_01.pdf
    3431233_Duck.pdf
    etc...
    So they have a 7 digit ID, then the file name which is always one of the 4 options (I'm just using the animals as examples, but they would be other words).
    What I'd want the script to do is categorize these into folders based on the ID number, and then based on the "animal" and then the files within them. Note, some files have an _01 or _02 etc... appended to them. I don't know if this makes a difference.
    So after running the script I'd love to see
    1234567 (Folder)
         Elephant (Subfolder)
              1234567_Elephant.pdf (File)
         Duck (Subfolder)
              1234567_Duck.pdf (File)
         Cat (Subfolder)
              1234567_Cat.pdf (File)
              1234567_Cat_01.pdf (File)
         Dog (Subfolder)
              1234567_Dog.pdf (File)
    3431233
         Elephant
              3431233_Elephant.pdf
         Dog
              3431233_Dog.pdf
              3431233_Dog_01.pdf
         Duck
              3431233_Duck.pdf

    well, using a couple of stock handlers I had lying around, and making the following assumptions:
    that an underscore is always the delimiter used
    that the file name is always a single word like 'dog' or 'cat' (if you have multiple word file names, the script needs to be modified some)
    this should do what you ask:
    set mainFolder to (choose folder) as text
    tell application "System Events"
      -- get all the unsorted files, and loop through
              set unsortedFiles to every file of folder mainFolder whose visible is true
              repeat with thisFile in unsortedFiles
      -- split the file name on underscores and periods
                        set fileNameBits to my tid(name of thisFile, {"_", "."})
      -- first item of list is id, make/get correct folder
                        set IDFolder to my checkForFolder(mainFolder, item 1 of fileNameBits)
      -- second item of list is file name, make/get correct folder in id folder
                        set groupFolder to my checkForFolder(IDFolder, item 2 of fileNameBits)
      -- move file
      move thisFile to groupFolder
              end repeat
    end tell
    to checkForFolder(fParent, fName)
      -- subroutine checks for folder, creating it if it doesn't exist
              tell application "System Events"
                        if not (exists folder fName of folder fParent) then
                                  set output to path of (make new folder at end of folder fParent with properties {name:fName})
                        else
                                  set output to (path of (folder fName of folder fParent))
                        end if
              end tell
              return output
    end checkForFolder
    on tid(input, delim)
      -- subroutine for handling text item delimiters
              set {oldTID, my text item delimiters} to {my text item delimiters, delim}
              if class of input is list then
                        set output to input as text
              else
                        set output to text items of input
              end if
              set my text item delimiters to oldTID
              return output
    end tid

Maybe you are looking for