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

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 15, 2008, 01:04 PM   #1
kelvinli
macrumors newbie
 
Join Date: Oct 2007
Applescript- Just started and i need help!!

Hi guys,

Just started learning some applescripts I need help in something regarding "looping (repeat) and naming curFile path"

this is my current code which i created for my Adobe Flash CS3 to automate some process. I want to loop it for several files.

Code:
tell application "Finder"
	set dFiles to every file of (choose folder)
	repeat with curFile in dFiles
		set this_item to curFile
	
		set this_path to the POSIX path of this_item		
		tell application "Adobe Flash CS3"
			activate
		end tell
		
		tell application "System Events"
			tell process "Adobe Flash CS3"
				click the menu item "New..." of the menu "File" of menu bar 1
				click the radio button "General" of the first tab group 
					of window "New Document"
				
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 126 --Up Arrow
				key code 36 --Enter
				
				click the menu item "Import to Stage..." of menu 1 of menu item "Import" of menu 1 of menu bar item "File" of menu bar 1 --Import
				--key code 15 using command down --Command + R (import)
				
				keystroke "/" using control down
				
				tell window "Untitled-1"
					tell sheet 1
						set value of text field 1 to this_path
						click button 1
					end tell
					click button 1
				end tell
				
			end tell
			
		end tell
		
		
		
		
	end repeat
end tell
I got an error once the line "set this_path to the POSIX path of this_item" is being runned. I cant loop this process if I cant get the path of the file...right?


I am able to do it in a single time not looping using this codes->
Code:
display dialog "Import an image file or a folder of images:" buttons 
	{"Cancel", "Folder", "Movie"} default button 3
if the button returned of the result is "Folder" then
	set this_item to choose folder
else
	set this_item to choose file
end if
-- convert the file reference to UNIX style

set this_path to the POSIX path of this_item

tell application "Adobe Flash CS3" to activate
tell application "System Events"
	tell process "Adobe Flash CS3"
		click the menu item "New..." of the menu "File" of menu bar 1
		click the radio button "General" of the first tab group 
			of window "New Document"
		
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 126 --Up Arrow
		key code 36 --Enter
		
		-- open import dialog
		keystroke "r" using {command down}
		-- summon path input sheet
		keystroke "/" using control down
		delay 1
		
		tell window "Untitled-1"
			tell sheet 1
				tell sheet 1
					set value of text field 1 to this_path
					click button 1
				end tell
				click button 1
			end tell
		end tell
		
		tell window "Import Video"
			delay 5
			key code 36 --Enter
			delay 5
			key code 36 --Enter
		end tell
		
	end tell
end tell
This works perfectly fine looking for the path of file.




I seriously need help. Any professional out there?
kelvinli 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
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
It's Started! lewismayell iOS 7 0 Jun 10, 2013 11:48 AM
Help getting started Redb3ard iPhone/iPad Programming 1 May 24, 2013 07:01 PM
Please HELP me get started! theuserjohnny Apple TV and Home Theater 15 Oct 28, 2012 11:06 PM

Forum Jump

All times are GMT -5. The time now is 10:51 AM.

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

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