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

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 24, 2012, 07:42 AM   #1
Polansky
macrumors newbie
 
Join Date: Nov 2010
Need applescript help - Copy files from desktop to NAS

Need some help with an applescript copying files from the desktop of my computer to the Synology NAS. I am really stuck.

The following would work for copying files from one folder to another folder on the desktop. Now I want to copy the files from the desktop to my NAS.

Is there someone who could please help me getting the files copied to my NAS instead of another folder on my desktop?

What I have so far:


Code:
property HDname : {"Mac OS X"}  -- Name of my internal HD

property User : {"Username"} -- The username I use on my Mac
property SourceHD : {"Mac OS X"} -- Name of my internal HD
property SourceFolder : {"Desktop", "test 1"} -- Sourcefolder
property TargetHD : {"Mac OS X"}
property DropFolder : {"Desktop", "test 2"}

property TargetVolume : {"NASname"}
property NASusername : {"NASusername"}
property NASpassword : {"Naspassword"}
property TargetVolumeFolder : {"Photography", "Photostream"}
Code:
-- Actual Script --
tell application "Finder"
	set sourcefiles to item 1 of SourceHD & ":Users:" & item 1 of User & ":" & item 1 of SourceFolder & ":" & item 2 of SourceFolder as alias
	
	set target_folder to item 1 of TargetHD & ":Users:" & item 1 of User & ":" & item 1 of DropFolder & ":" & item 2 of DropFolder as alias
	
	
	try
		duplicate (every file of the entire contents of sourcefiles whose name extension is in {"JPG", "NEF", "RAW", "RAW2"}) to the target_folder with replacing
		
	end try
end tell

-- END Script --

Obviously the above script works for copying files from folder A to folder B on the same HD. Now I want it to copy to my NAS, but need some help from somebody on how I do this.

Your help will be greatly appreciated!

Last edited by balamw; Dec 24, 2012 at 04:06 PM. Reason: CODE tags
Polansky is offline   0 Reply With Quote
Old Dec 24, 2012, 01:08 PM   #2
Polansky
Thread Starter
macrumors newbie
 
Join Date: Nov 2010
Solved my own problem.

For those who also want to copy files from their desktopfolder to their NAS system, you can use the following applescript:


--
Code:
property User : {"username"} -- The Username you use on your Mac
property SourceHD : {"Macintosh HD"} -- The name of your Mac Computer (HDD)
property SourceFolder : {"Desktop", "test 1"} -- Your sourcefolder(s)

property NASuser : {"nasusername"} -- The Username on your NAS
property NASpassword : {"naspassword"} -- The Password of your NAS
property NASVolume : {"sharedfolder"} -- NAS Shared Folder name
property NASDropFolder : {"folder1", "folder2"} -- The destination folder(s) on you NAS



on idle
	Loop()
	return 10
end idle
Code:
-- Actual Script --
on Loop()
	tell application "Finder"
		set sourcefiles to item 1 of SourceHD & ":Users:" & item 1 of User & ":" & item 1 of SourceFolder & ":" & item 2 of SourceFolder as alias
		try
			set target_folder_1 to item 1 of NASVolume & ":" & item 2 of NASDropFolder as alias
			set mounted_Disks to list disks
			if mounted_Disks contains item 1 of NASVolume then
				duplicate (every file of the entire contents of sourcefiles whose name extension is in {"JPG", "NEF", "RAW", "RAW2"}) to the target_folder_1 with replacing
				
				-- Only use the following line if you want to delete the files in the source folder
				delete (every file of the entire contents of sourcefiles whose name extension is in {"JPG", "NEF", "RAW", "RAW2"})
			end if
		end try
	end tell
end Loop
--

Export the file as application / don't close

Last edited by balamw; Dec 24, 2012 at 04:07 PM. Reason: CODE tags
Polansky is offline   0 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
Copy files to folder using Applescript Kitkat88 Mac Programming 7 Jun 23, 2014 07:45 AM
Can not copy files to the desktop after recover from TC? Fender3 iMac 0 Nov 13, 2013 03:30 AM
iPad: how to copy .ipa files from Desktop to ipad and install ? jigsb007 Jailbreaks and iOS Hacks 19 Aug 30, 2013 11:47 AM
Use applescript automatic copy Specified files from new added Mobile hard disk to mac woshiysc Mac Programming 10 Feb 22, 2013 10:20 AM
Can't copy a few files from iPhoto to the desktop aircanman MacBook Pro 0 Nov 11, 2012 06:24 PM

Forum Jump

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

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