Current Position:Home > Using Automator and Applescript to search and move files to flash drive

Using Automator and Applescript to search and move files to flash drive

Update:11-30Source: network consolidation
Advertisement
I've used applescript and automator to do simple tasks like watch folders and move files and rename files, but that is about the extent. I am wondering if it is possible to set up a automator service or app that will do several things.
When a flash drive is plugged it, it will ask for a file to be searched for, then it will search a predetermined directory for files with the word or number in them and then it will copy the found files to the mounted flash drive.
Any help would be greatly appriciated!
Thanks!

The Best Answer

Advertisement
As a start, you can use launchd to run a script when a volume is mounted:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
          <key>Label</key>
          <string>com.tonyt.LaunchOnVolMount</string>
          <key>ProgramArguments</key>
          <array>
                    <string>LaunchOnVolMount.sh</string>
          </array>
          <key>QueueDirectories</key>
          <array/>
          <key>StartOnMount</key>
          <true/>
          <key>WatchPaths</key>
          <array/>
</dict>
</plist>
You can then have the LaunchOnVolMount.sh script perform the tasks you need.
You can incorporate Applescript within the Bash script with osascript:
#!/bin/bash
answer=$( osascript -e 'tell app "System Events" to display dialog "What file do you want to search for?" default answer "" ' )
echo $answer
I beleive that you can also call an Applescript from launchd
  • Using Automator and Applescript to search and move files to flash drive Update:11-30

    I've used applescript and automator to do simple tasks like watch folders and move files and rename files, but that is about the extent. I am wondering if it is possible to set up a automator service or app that will do several things. When a flash d

  • Automator or Applescript to Rename Subfolders and Files Update:11-30

    I have 200 Gigs of files that need to be moved from a Mac's internal drive onto an external non-mac formatted drive for storage (Buffalo TeraStation). Obviously there is an issue with illegal characters in some of my filenames and folder names. I was

  • DSX-S310BTX Media Player: How Do You Need To Label mp3 Files On Flash Drive To Search Internal USB? Update:11-30

    I have a DSX-S310BTX Media Player.  I'm connecting a Flash Drive to the Internal USB port of this device.  On the flash drive the mp3 files are labled by Title, Contributing Artist and Album.  However, when a song is playing, the main display doesn't

  • Search for a file on hard drive? Update:10-11

    Hi, Any method available to search for a group (e.g : *.exe of file on server and return the names of those files, if any? Thanks.The way I would do it is with a search object that starts at the top of the drive, C: in windows, and gets all files usi

  • Stopping Automator "Run Applescript" if file not found. Update:11-30

    Hi all, I'm creating a folder action that, when a file is added to the folder, will search the folder to see if the file is of a certain type (by the extension) and then run an Applescript that will open the file in the appropriate program. The probl

  • Automator and applescript to copy new files in a folder with same name as parent folder Update:10-11

    I have an iMac with a pictures folder (Finder folder) containing several subfolders with pictures. As per now, all these subfolders are imported into an iPhoto library (and the structure of the Finder pictures folder is thus maintained: The iPhoto ev

  • Applescript Help: Search for text in Safari DOM tree Update:10-11

    Im trying to make a script really similar what was asked here: Re: Find text in webpage and email notification applescript/automator Except instead of searching the "source code" of the page, I want the script to search the "DOM tree"

  • Automator or Applescript using png files with alpha channel Update:10-11

    I have hundred of png files with alpha channel. I want to suppress alpha channel. How can i do it using Automator or Applescript ? Thank you very much.You can use the free command line image processing tool ImageMagick in your Applescripts or Automat

  • Using automator or applescript in Preview Update:11-30

    Hi All, I'd like to create a services menu item in Preview which does either of two things: Open the file I'm currently viewing in Canon DPP raw processing software OR Check for a folder called "Keepers" in the same directory as the file I'm cur

  • Getting Automator or AppleScript to start up QuickTime and play a radio sta Update:11-30

    I am new to Automator and have never tried AppleScript. I would like my Mac to start up and play a radio station. I have been successful in getting the link to work in QuickTime or play directly in Safari. However, when I try to use Automator to star