Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 19, 2013, 03:38 AM   #1
woshiysc
macrumors newbie
 
Join Date: Nov 2012
Location: Shenzhen,China
Use applescript automatic copy Specified files from new added Mobile hard disk to mac

hi,guys
I use a 2012mac mini as a home server,after read some applescript introduce,I found a vast space about automatic processing on Mac OS.

Now I am thinking use a applescript copy the specified files from new added Mobile hard disk to Mac mini when the new disck just connected to mac mini.

For example:
a USB hard drive have movie/music/pic/ folders,when it connected to mac mini,the script can automatic copy those folders' files to mac itself at different folders.
If script can do more,I wonder it can identify different extend of files,that can make mkv/avi/rmvb as movie files copy to mac's movie folder,mp3/m4a as music files copy to music folder,so as pic.

Expression may not be detailed,looking forward to your answers!

Last edited by woshiysc; Feb 19, 2013 at 07:51 AM. Reason: applescript folder
woshiysc is offline   0 Reply With Quote
Old Feb 19, 2013, 09:43 AM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
There's a couple of ways to do what you want. Applescript or a combination of Applescript and a LaunchAgent or another application or a System preference pane. You might want to take a look at DSW. Do Something When is a system preference pane that allows the user to watch for drives mounting and un-mounting, allowing them to launch or quit applications, when these events happen. This in combination with an Automator app or Applescript app should do the trick. You could do something like this with Automator actions :
  1. Find Finder Items whose kind is Movie
  2. Copy Finder Items
  3. Find Finder Items (Ignore Input) whose kind is Audio
  4. Copy Finder Items
  5. Find Finder Items (Ignore Input) whose kind is Image
  6. Copy Finder Items

Info : http://www.azarhi.com/Projects/DSW/index.php
Attached Thumbnails
Click image for larger version

Name:	Picture 5.png
Views:	433
Size:	98.4 KB
ID:	398040  
__________________
Space Corps Directive 34124

Last edited by kryten2; Feb 20, 2013 at 02:33 PM.
kryten2 is offline   1 Reply With Quote
Old Feb 20, 2013, 02:28 AM   #3
woshiysc
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Location: Shenzhen,China
Quote:
Originally Posted by kryten2 View Post
There's a couple of ways to do what you want. Applescript or a combination of Applescript and a LaunchAgent or another application or a System preference pane. You might want to take a look at DSW. Do Something When is a system preference pane that allows the user to watch for drives mounting and un-mounting, allowing them to launch or quit applications, when these events happen. This in combination with an Automator app or Applescript app should do the trick. You could do something like this with Automator actions :
  1. Find Finder Items whose kind is movie or pic or Movie
  2. Copy Finder Items
  3. Find Finder Items (Ignore Input) whose kind is Audio
  4. Copy Finder Items
  5. Find Finder Items (Ignore Input) whose kind is Image
  6. Copy Finder Items

Info : http://www.azarhi.com/Projects/DSW/index.php
Thank you vvvvvvery much for your answer!
It's really very helpful!
But I still have two questions:
1.How can the script avoid copying same files when mounting USB drive times.
2.If I mount different drives with different names,can the Automator identify them and copy the files,I search the DSW and it may achieve this function,but I tend to use applescript or Automator release the function.

Looking forward to your wonderful answer!
woshiysc is offline   0 Reply With Quote
Old Feb 20, 2013, 09:47 AM   #4
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
1) I may be wrong on this but if you check Replace existing files in the Copy Finder Items the file will be replaced. If you leave it unchecked and the file exists it will not be copied.
2) Make a rule in DSW for every external disk and for every rule make a workflow with changes made to the where part in the Find Finder Items pointing to the correct external disk.

You're not the first person to ask to do something when a drive mounts. It can be done with Applescript but it will take some time and work from you to put it all together. You can also attach a folder action to the /Volumes folder. I've included some more info to get you started.

Info : http://stackoverflow.com/questions/1...rt-a-usb-drive
http://hintsforums.macworld.com/show...99&postcount=6
__________________
Space Corps Directive 34124
kryten2 is offline   1 Reply With Quote
Old Feb 20, 2013, 12:19 PM   #5
woshiysc
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Location: Shenzhen,China
Quote:
Originally Posted by kryten2 View Post
1) I may be wrong on this but if you check Replace existing files in the Copy Finder Items the file will be replaced. If you leave it unchecked and the file exists it will not be copied.
2) Make a rule in DSW for every external disk and for every rule make a workflow with changes made to the where part in the Find Finder Items pointing to the correct external disk.

You're not the first person to ask to do something when a drive mounts. It can be done with Applescript but it will take some time and work from you to put it all together. You can also attach a folder action to the /Volumes folder. I've included some more info to get you started.

Info : http://stackoverflow.com/questions/1...rt-a-usb-drive
http://hintsforums.macworld.com/show...99&postcount=6
Very helpful information.
I had aready thought about folder action,but don't know which folder to watch and the next steps!
Those information are exactly in line with my idea!
Thank you very much again,and I have to learn those data and release the idea on my Mac mini~
woshiysc is offline   0 Reply With Quote
Old Feb 20, 2013, 06:55 PM   #6
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
See PM :
Attached Files
File Type: zip Screenshots.zip (443.7 KB, 81 views)
__________________
Space Corps Directive 34124
kryten2 is offline   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to carbon copy an old hard disk with mountain lion on MBP-retina's SSD player1024 MacBook Pro 3 Oct 18, 2014 11:46 AM
Can't copy files from my external hard drive Simont83 OS X 4 Aug 21, 2014 02:14 PM
Copy files to folder using Applescript Kitkat88 Mac Programming 7 Jun 23, 2014 08:45 AM
Can a mac do a bitwise copy of a USB disk with proprietary disk format? deacLL OS X Mavericks (10.9) 10 Apr 10, 2014 08:14 AM
Need applescript help - Copy files from desktop to NAS Polansky Mac Programming 1 Dec 24, 2012 02:08 PM

Forum Jump

All times are GMT -5. The time now is 09:56 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC