From PC to MAC - Scripting help and a kick in the right direction

Hi There,

For 2 years now i have been using Parralels on my MAC to run some simple macros to do my repetitive renaming and copying tasks for me. Recently my company has asked that I wind down using parallels as the new outlook for MAC is good enough to implement so they are trying to phase out windows.

Having no objections to what OS I use i need to find the best way to rewrite my automation scripts using a mac.

I have purchased a couple of books on AppleScript but am not overly excited by its over use of vocab and what seems like long winded ways of doing things. I am not a programmer or even a good scripter, I am actually a video editor that spent a couple of years on a computing degree so i have some basic knowledge of programming etc… anyways, I am looking for some guidnace in the best way to do things and for someone to take a look at my workflow and suggest some methods to help out!

I used a AutoHotKey to write my macros in windows and it gave me a simple GUI with options to process the correct files and send files to the correct locations…

I dont need to have a GUI but was looking to have a workflow like this:

Have a designated export folder for my video files. Once it has exported to this folder i want a copy to be renamed and sent to a network folder, then an option box that gives me the option of archiving and encoding or quitting… click archive and encode would send a version of this file to a local hard disk in a dated archive folder and also send the version to another network folder (encoder).

How would i do this?

I found this and adjusted it slightly and it kinda works but doesn’t copy the file over correctly…


on adding folder items to this_folder after receiving added_item
	set video_folder to "GLYPH-1500 GB:FcpExportsArchive:"
	set target_folder to "GLYPH-1500 GB:FcpExportsArchive:" & (do shell script "date +%m%d%y")
	try
		get target_folder as alias
	on error
		tell application "Finder" to make new folder at video_folder with properties {name:do shell script "date +%m%d%y"}
	end try
	repeat with anItem in added_items
		
		set newFile to (POSIX path of target_folder & prefix & "." & name extension of (info for anItem))
		do shell script "/bin/mv " & quoted form of POSIX path of anItem & space & quoted form of newFile
		display dialog "hello" & quoted form of newFile
		delay 1
	end repeat
end adding folder items to

I also have this to create a dated folder linked to iCal daily:


tell application "Finder"
	set the_date to do shell script "date +%m%d%y" --Changes the format of the date to MMDDYY
	set dest_folder to folder "FcpExportsArchive" of disk "GLYPH-1500 GB" -- sets location of archive folder
	make new folder at dest_folder with properties {name:the_date} --creates the folder
end tell

Any tips and help figuring out where to start would be greatly appriciated.
Thank you!
Tom

Hi,

this one (wrote it a few weeks ago as folderaction) should move the files which are added in a folder to a “yearMonthFolder” of a specified folder. Files Prefix will be changed to “yearMonthDay”.

Try playing around …

on adding folder items to this_folder after receiving these_items
	
	set _path to (path to desktop as text) & "YourFolder:"
	
	tell (current date)
		set _day to my _leading(((its day as number) as text))
		
		set _month to my _leading(((its month as number) as text))
		
		set _year to (its year as text)
	end tell
	
	set {TID, text item delimiters} to {text item delimiters, ":"}
	
	repeat with i from 1 to count of these_items
		try
			set _file to item i of these_items
			set _fName to (_year & "_" & _month & "_" & _day) & "_" & (text item -1 of (_file as text))
			set _dirPath to (_path & _year & "_" & _month)
			do shell script "mkdir -p " & quoted form of POSIX path of _dirPath
			do shell script "mv -f " & quoted form of POSIX path of _file & space & quoted form of POSIX path of (_dirPath & ":" & _fName)
		on error e
			display dialog e
		end try
	end repeat
	
	set AppleScript's text item delimiters to TID
end adding folder items to

on _leading(_string)
	if (count of _string) is 1 then
		return "0" & _string
	else
		return _string
	end if
end _leading

Works well, thanks!