New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Auto-Copy script


Post Reply New Thread Subscribe

 
Thread Tools
StevenJ

 
Member Since: Aug 06, 2009
Posts: 5
StevenJ is on a distinguished road

StevenJ is offline
I am fairly computer literate & have some knowledge of UNIX scripts from the past......


I have been a windows/PC user forever, but bought a Mac laptop a year ago after my PC laptop broke....brilliant decision!

Anyway, I use external hard-drives to back up my large digital library of photographs....I use a windows batch file located on the hard drive that runs automatically when I plug it in the USB port on the PC....it works perfectly.

I am wanting to ditch the PC, and move to MAC completely, but I still need to be able to have the ability to plug in a USB drive, it copy the desired directories I wish to it.

How do I get a script located on the USB drive to automatically run when I plug in a USB drive?


I actually have no idea where to start! I can figure out the 'cp' comands myself, but getting the script to 'call' in the firstplace I am lost.....!
QUOTE Thanks
Slydude

 
Slydude's Avatar
 
Member Since: Nov 15, 2009
Location: North Louisiana, USA
Posts: 6,087
Slydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant future
Mac Specs: 2.8 GHz MacBook Pro 10.8,3 8 GB mem, 2.66 GHz Mac Pro - Dead, iPhone 4

Slydude is online now
I am going to try this with Automator soon but until I have time to work on it these references might get you started. The second link is based upon using an excellent backup program called Super Duper. I suspect either script would be east to modify.

Use a run-on-drive-connect SuperDuper backup script - Mac OS X Hints

SuperDuper Bash Script to Automatically Mount or Unmount a Hard Drive ? T?N?T Luoma

Sylvester Roque Former Contributing Editor About This Particular Macintosh

"Got Time to breathe. You got time for music." Denver Pyle as Briscoe Darling
QUOTE Thanks
MacsWork

 
MacsWork's Avatar
 
Member Since: May 22, 2005
Location: Closer than you think.
Posts: 2,132
MacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really nice
Mac Specs: Performa 6116 2GBSCSI 8MB OS 7.5.3

MacsWork is offline
What is calling the batch file? Surely a batch file cannot execute itself when a drive is inserted.

You'd need to create some sort of launch agent or daemon to be listening for USB connectivity.

Is it a specific drive or any USB drive? Does it prompt you for input?
QUOTE Thanks
Slydude

 
Slydude's Avatar
 
Member Since: Nov 15, 2009
Location: North Louisiana, USA
Posts: 6,087
Slydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant future
Mac Specs: 2.8 GHz MacBook Pro 10.8,3 8 GB mem, 2.66 GHz Mac Pro - Dead, iPhone 4

Slydude is online now
I am just starting to look at this and I'm not much of a scripter that is why I was going to use Automator. Here is one way the script could probably be called. Perhaps others can chime in with the specifics till I have a chance to work out the details:

There is an invisible folder on the Mac called /Volumes When a drive mounts it will appear there. The script would check for the correct drive and either execute or not depending upon whether the right drve is present. Once the script is written it can be saved as a folder action. Folder actions execute when there is a change to a specific folder
Folder Actions for OS X explained – with real-world examples – Simple Help

Sylvester Roque Former Contributing Editor About This Particular Macintosh

"Got Time to breathe. You got time for music." Denver Pyle as Briscoe Darling
QUOTE Thanks
McYukon

 
McYukon's Avatar
 
Member Since: May 14, 2009
Location: Near Whitehorse, Yukon
Posts: 2,053
McYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to beholdMcYukon is a splendid one to behold
Mac Specs: 2012 MBP i7 2.7 GHz 15" Matte - 16 GB RAM - 120 GB Intel SSD - 500 GB DataDoubler Mac OS 10.9

McYukon is offline
Here's a example that is almost what your wanting to to,
Autorun finder when plugging in USB Stick - MacRumors Forums

Use the reputation system if a post helps you!
Mac Forums IRC Channel - Help build it by hanging out with us
The next sentence is true. The previous sentence is false.
QUOTE Thanks
Slydude

 
Slydude's Avatar
 
Member Since: Nov 15, 2009
Location: North Louisiana, USA
Posts: 6,087
Slydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant futureSlydude has a brilliant future
Mac Specs: 2.8 GHz MacBook Pro 10.8,3 8 GB mem, 2.66 GHz Mac Pro - Dead, iPhone 4

Slydude is online now
Should have known you would pick up the ball and run with it. lol. I had forgotten about Do Something When.

Sylvester Roque Former Contributing Editor About This Particular Macintosh

"Got Time to breathe. You got time for music." Denver Pyle as Briscoe Darling
QUOTE Thanks
StevenJ

 
Member Since: Aug 06, 2009
Posts: 5
StevenJ is on a distinguished road

StevenJ is offline
thanks for info.....

w.r.t. the batch file, I wrote a basic DOS batch file, and it is located on any external drive you wish to put it on. When you plug a drive in on windows, you can select an action it will carry out every time 'that particular drive' is connected. I simply set it to execute the batch file I have saved on the drive. I will look in to the folder actions, but would like to achieve this before buying an iMac!

I would have to refresh my memory with my UNIX commands, but the script would simply be 'cp' commands.....with switches only to copy updated/changed files......

e.g.

cp /switches /Users/stevenjparkes/Pictures ./ and re-direct the output to some.log
QUOTE Thanks

Post Reply New Thread Subscribe


« safari browser window missing | Singing MacBook - How to turn off voice? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Script to duplicate Apple Lossless iTunes library as MP3 files nick_harambee OS X - Operating System 10 10-02-2010 08:53 AM

All times are GMT -4. The time now is 10:24 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?