Does any know how to detect the name of the IOS device connected via a cable on macOS through AppleScript.

This does every source but I'm looking to identify the source.

tell application "iTunes"
    tell every source whose kind is iPod to update
end tell


  • Are you after the name of the device or its UUID? Because if you're after the UUID you could just run the command system_profiler SPUSBDataType | grep "Serial Number" in terminal to obtain this. I'm sure you could program it into Apple Script (but i'm not sure how to!)
    – AVelj
    Jan 28, 2022 at 4:03
  • Additionally, you might want to investigate libimobiledevice tool, which you can install on your Mac and use in terminal. It provides a lot of diagnostic tools that can be used to find detailed information for your iOS device when plugged into the Mac. In your case - once it's installed, you could run the command ideviceinfo | grep "DeviceName" to get the name of your device, but ideviceinfo provides way more detailed information you might also be interested in :)
    – AVelj
    Jan 28, 2022 at 4:12

1 Answer 1


Assuming that you have a single usb-connected device… this will generate a single-item list:

tell application "iTunes" to sources whose kind is iPod
--> {source id 12345 of application "iTunes"}

You can get the properties of the source with:

tell application "iTunes" to properties of item 1 of (sources whose kind is iPod)
--> {class:source, id:12345, index:4, name:"iPaddo", persistent ID:"AABBCCC66F695000", kind:iPod, capacity:6.0455927808E+10, free space:1.20541315E+10}

And as one of those properties is name, you can get the name this way:

tell application "iTunes" to name of item 1 of (sources whose kind is iPod)
--> "iPaddo"
  • thanks for this code. Would you also know for new operating systems that do not have iTunes any more? (finder sync)
    – Lacer
    Jan 30, 2022 at 2:38
  • Try "Music" if you have a recent version of the OS. I believe that is the name of the apple app that has replaced itunes.
    – Mockman
    Jan 30, 2022 at 5:36
  • doesn't work "error "The variable iPod is not defined." number -2753 from "iPod"
    – Lacer
    Jan 30, 2022 at 15:06
  • With it plugged in, try kind of sources. It should generate a list with one item referring to the plugged-in device. You can also (presumably) look in Music's applescript dictionary for 'sources' and see what the listed varieties under 'kind' are. Maybe apple has removed 'ipod' from the list but hopefully, they've also replaced it.
    – Mockman
    Jan 30, 2022 at 18:44
  • To explain what likely happened… source is a class. Each item that is a source has properties, one of which is kind. The dictionary enumerates the different kinds of sources, which in itunes included library, audio CD, etc… as well as ipod. ipads were deemed 'ipod' for these purposes. Apparently, apple has done away with 'ipod' as a kind of source. So when you try to run/compile your script under Music, the word 'ipod' isn't recognised and so the compiler assumes that you meant it as a variable (because the word is no longer in the list), and thus the 'not defined' error.
    – Mockman
    Jan 30, 2022 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .