Can I use Applescript or Automator to automatically eject my external drive before the battery dies?

Whenever I leave my macbook unplugged with my external hard-drive plugged in and the battery power runs out, my computer "dies" and my external hard-drive is not ejected properly, sending me a warning that data may be lost if not ejected properly. This has happened on several occasions.
Is it possible to program my external hard-drive to eject itself when my computer is running low on battery power so I do not have to worry about losing data from being ejected misproperly?
My system specs:
  Model Name:          MacBook
  Model Identifier:          MacBook1,1
  Processor Name:          Intel Core Duo
  Processor Speed:          2 GHz
  Number Of Processors:          1
  Total Number Of Cores:          2
  L2 Cache:          2 MB
  Memory:          2 GB
  Bus Speed:          667 MHz
  Boot ROM Version:          MB11.0061.B03
  SMC Version (system):          1.4f12
  Sudden Motion Sensor:
  State:          Enabled
I'm using a WD Passport 250 GB notebook external hard-drive.
Note: I use my external for time machine as well as for storing my entire iTunes library to free space on my macbook.

Alright, after trying stuff for some irritating hours, I think I've got something you can use. I haven't figured out how to get it to run all the time.
(I must be an idiot becuase I can't find where to upload this file)
Automator application
Run Shell Script (ignore this actions input)
ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'
Set Value of Variable
Variable: new variable... (I called it Battery Life)
Run AppleScript
on run {input, parameters}
          if input is less than "3.00" then tell application "Finder" to eject (every disk whose ejectable is true and local volume is true)
          return input
end run

Similar Messages

  • Can I use Time Machine to backup to partition on external drive and a Time Capsule?

    Trying to plan in advance...
    I was wondering if I can (with a laptop) use Time Machine for both:
    1. Creating Time Machine backups on a partiion of an external drive. My plan was going to create  2 partitions: one to be used for Time Machine backups of another external hard drive (that holds all of my media) and then the other partition was going to be a bootable clone of my internal drive (totally separate from Time Machine)
    and
    2. Also use Time Machine for my Time Capsule, to create Time Machine backups of my internal drive.
    Is this possible? I had heard that you can't use TM to make backups to a partition on an external drive, AND use it for another drive (like Time Capsule) at the same time. But I would think that this should be possible-
    Thanks everyone-

    Yes you can, and if you are using Mountain Lion it's easy.
    If you are using Snow Leopard (as in your profile - this is the Mountain Lion forum), you have to manually select the backup volume each time. Tedious, but possible.
    Read Apple Support Communities contributor Pondini's FAQ on that subject: "Rotating" Time Machine backup disks

  • Can I use my late 2006 mac mini as an external drive for my late 2012 mac mini?

    I have a (late 2006) Mac mini that I would like to use as an external drive for my (late 2012) Mac mini.  Is this possible and can anyone suggest what cables would be needed.  I am aware that the ports are very different i.e firewire and thunderbolt.  Thanks in advance!

    - You can boo the old Mac in Targe Disk Mode and connect the two via FireWire (FW) You will need a FW 400 to FW 800 cable or a FW 800 or FW 400 cable and appropriate adopters
    How to use and troubleshoot FireWire target disk mode - Apple Support
    - Use the old Mac normally and setup Disk Sharing and access the old Mac via the network. The old Mac's disk will show up  under Devices on the new Mac. One you set up the old Mac yo do not need mouse or keyboard or monitor. You can also setup Screen sharing and actually use the old Mac from the new Mac.
    - Remove the HD from the old Mac and place it in an external USB enclosure of dock and connect it to the new Mac

  • How long can the iPhone 3GS record video before the battery runs out?

    My father invested in an iPhone 3GS Tripod adapter for his tripod, for some conferences and lectures. He has a 16GB 3GS, which will record about 8.6 hours, according to another thread I've read about on here. But he doesn't really want to bring the USB/Adapter cable with him, and have to worry about finding a power outlet. Assuming his phone is on full charge, and bluetooth/wifi are shut off, and brightness is kept a bit dim (not too dim) - can anyone give me a round about answer of how long the it will record video before the battery dies? This function is today, so timing is critical. I will have him take the charger/usb with extension cable just in case. I'd appreciate anyones input

    Not sure if the battery will die before or after your done recording on the iPhone.But most sites are claiming that you can record up to 2GB per video.I just recorded a one minute clip,and it rounded off to about 34MB.So if you devide that,it rounds off to around an hour of recording video...But take that with a grain of salt,I'm not good with math lol

  • How can I use Applescript to copy a file's icon to the clipboard?

    Hello,
    How can I use Applescript to copy a file's icon to the clipboard?
    Thanks.
    Lennox

    there is no way to do that that I know of. but you can extract an icon of a file to another file using command line tool [osxutils|http://sourceforge.net/projects/osxutils]. you can then call the relevant command from apple script using "do shell script".

  • How can I use AppleScript Studio to display an image

    How can I use AppleScript Studio to display an image in a dialog?

    Add an image well to your window in Interface Builder.
    You can also add an image file to the Resources group of your Xcode project and then set the image to be displayed inside the image well directly in Interface Builder. No AppleScript code is needed if the image is contained within your app bundle and can be set ahead of time like this.
    If the image is contained in your app's bundle but you need to set or change the image at run time then you can use a line of AppleScript to load it into the image well using just it's filename:
    set image of image view "yourImageView" of window "yourWindow" to load image "YourImageFile.jpg"
    If you need to load an image from an arbitrary location outside your app's bundle then use a path to the image file...
    set image of image view "yourImageView" of window "yourWindow" to load image "/path/to/YourImageFile.jpg"
    Steve

  • Can I use Time Machine to back files on an External Hard Drive

    My MacBook Pro hard drive filled up with movies, pictures, and music, so I bought a 2TB Time Capsule.  I have a external hard drive that is about the same capacity as my MacBook hard drive. Sine the Time Capsule is by far the largest drive I have, I moved all my movies, music, and pictures to the Time Capsule and am using it as an external hard drive.  I attached a 500GB external hard drive to the Time Capsule and I use that as the backup drive for Time Machine. However, the problem I am encountering is that I can't seem to direct Time Machine to include all of my files on my Time Capsule in the back up on to the other external hard drive. 
    Can I use Time Machine to backup data that I store on my Time Capsule to a external hard drive?  If not, what is hte best method for backing up my files that are on my Time Capsule?
    Thanks,
    David

    You need to use a different utility .. eg CCC or Chronosync to backup from the TC to yet another drive.. the problem is, that drive should be connected to the computer.. if you use a USB drive on the TC.. the file copying will be slow as slow as you will not believe.. all files are copied to the computer, then back to the TC.. it cannot copy directly to the TC..
    As Neil said.. one way or another you need to use an external drive on the computer, even if you don't use it all the time.. the danger of course is not doing regular backups.. and forgetting their importance.
    A true NAS will have automated backup incrementally of the files stored.. The TC is not a NAS in that sense.. it is a backup target for TM above and beyond anything else.

  • Can I use time machine to back up via a hard drive connected by USB to a HomeHub router?

    Can I use time machine to back up via a hard drive connected by USB to a BT HomeHub router? Is there a better way to back up and store files than via the USB port on my new MacBook Pro? I'd like storage to be accessible from my earlier version MacBook too.

    I think you want to make backups without connecting a hard disk via USB. In other words, you want to have the data storage be shared in your home wirelessly.
    If this is the case, I recommend using a Time Capsule.
    Time Capsule works great with Time Machine. You can set up all your devices to automatically make backups on the Time Capsule wirelessly and effortlessly.

  • What formula in numbers can I use when I want to know how much 19 % is of the numbers from (let's say) e6 up to e27 ?  thank you

    what formula in numbers can I use when I want to know how much 19 % is of the numbers from (let's say) e6 up to e27 ?  thank you

    thanks a lot jerry.
    Can I ask you another question?
    it works well but it gives me a number like  14,567
    and I would like it if it will automatic round up an give me the number 15 in this case.
    I do know the seperate folmula to round up numbers but can I combine the two formula's ?
    thank you and bye bye

  • I would like to know if you have to back up a macbook hard drive, can I use a external hard drive that has been previously used to back up several pc 's, or is it best to have a separate external drive for the Mac?

    I would like to know if you have to back up a macbook hard drive, can I use a external hard drive that has been previously used to back up several pc 's, or is it best to have a separate external drive for the Mac?

    In the Mac side of things, backups usually come in two flavors: clones or incrementals.
    A bootable clone is a bit-for-bit copy of all essential files in the startup volume. If using the Lions, clones can be made using CarbonCopyCloner or just plain old Disk Utility. These backups represent the safest protection of your info, but take the longest to do. Recovery is an inverse process: you copy the clone back into the internal drive.
    Incremental backups start with a complete backup of the startup volume and only copy whatever changed from the previous run. OS X includes the fully integrated Time Machine backup utility to do this. It is extremely easy to do and takes the least amount of time. Recovery is another matter altogether since you have to start with a freshly installed instance of the OS and have to apply all intervening backups to bring the result to the latest saved version.
    As for where the backup takes place, the recommended media is an external dedicated drive or drives connected via the fastest interface available on your Mac: Thunderbolt, USB3, Firewire, or USB2. Network-based backups, wired or wireless, are attractive but may not offer the same performance and hence take longer. Also important to note that the entire drive need not be completely dedicated to a single backup. The Mac's EFI firmware infrastructure allows for an unlimited number of partitions on a hard drive and each can be used for either type of backups.
    Holler if you need specifics on how to do each. This was just an executive summary.

  • Can I use a mini CD-R in my PowerBook CD Drive?

    Can I use a mini CD-R in my PowerBook cd drive? I wanted to transfer some photo's to the Sony Mini CD-R that came with a PSP to then put on the PSP.
    But the Mini CD-R is so small I'm afraid to try to slide it into the PowerBook cd slot and not get it out.
    Thanks

    Can I use a mini CD-R in my PowerBook cd drive?
    No.
    ... the Mini CD-R is so small I'm afraid to try to slide it into the PowerBook cd slot and not get it out.
    That's exactly what can happen.
    Apple says don't do it.

  • Can i use my iphone 4 warrenty to get a early upgrade to the iphone 5c

    I need to know because my iphone 4 is slowing down, the battery dies fast than usual even if im not using it and also my iphone freezes out of no where texts random messages without me writing or sending them. So can someone please help me thank you

    No. Apple warranties do not help you get early upgrades on devices. If you think something is wrong with your device then take it to the nearest Genius Bar.

  • Can I use an radar alarm on my iphone 4, without passing by the telephone card, for example in plane mode?

    Can I use an radar alarm on my iphone 4, without passing by the telephone card, for example in plane mode? This question in order to avoid the roaming when I leave my country for a foreigner one

        Hi there Eartley! That sounds like an amazing opportunity for you! I am glad you are going to be able to study in Italy. The iPhone 6 is an excellent phone to travel with and you should have no problems using a local SIM card while you are in Italy. While I have not been to Italy myself and can not make recommendations for service providers out there, our Global Support Team may be able to help out! Here is where you can get in touch with them http://vz.to/1DgQ1IJ . Have a great trip!
    bryans_vzw
    Follow us at Twitter @vzwsupport

  • You can download past purchases on this computer with just one Apple ID every 90 days. This computer can be used with a different Apple ID in 71 days. Whats the deal???

    You can download past purchases on this computer with just one Apple ID every 90 days. This computer can be used with a different Apple ID in 71 days. Whats the deal???

    You can use multiple AppleIDs to purchase new music but you are limited as to how frequently you can change authorizations for re-downloading  past purchases.  It may well be a measure to deter piracy by stopping a group of people from going around to a friend's computer and downloading purchases on the other person's computer.  It is easy to avoid by making sure you have backup copies on drives at home so you never need to redownload anything.

  • I use my 7th gen ipod on bluetooth and when the battery dies while on bluetooth it wont turn on or charge and the computer doesnt find it.  This is my 2nd nano in just over a month.  The first one had the same problem.  how can i fix this?

    I have the latest ipod nano (7th gen, 16gb) and I use it mostly on bluetooth. When the battery dies during use with the Bluetooth it doesn't take a charge, the battery doesn't turn on and of course the computer doesn't even acknowledge that it's plugged in. This is my second nano in just over a month, the same thing happen with the first one. I just want to know if their is a way to fix this so I don't have to keep sending it in? Or maybe pay the difference to upgrade to a touch?

    If the battery has been completely depleted on the Nano (not really a good idea) then it is going to take 15 to 30 minutes before your computer can see it. Same thing will happen with an iPod Touch.

Maybe you are looking for