Applescript Safari Find action
Hi im new to applescript and im just wondering if anyone can help me out with my problem...
i was wondering if someone can show me how to make applescript continuously refresh a page in safari and everytime it refereshes a page.. it performs the "find" action to look for a certain text... and if its not there it repeats the "refresh and find" action until the text finally appears on the page - in which case the script would stop while the text im looking for remains highlighted.
hi there,
thank you for your reply.. but im not entirely sure how to adapt that cURL script to what i want to do.
basically while safari is open... i want the script to find lets say for example the number 164 (which keeps disappearing and appearing randomly on the page)
the script may be something along these lines:
tell application "Safari" to activate
tell application "System Events"
click menu item 8 of ((process "Safari")'s (menu bar 1)'s ¬
(menu bar item "Develop")'s (menu "Develop")'s ¬
(menu item "User Agent")'s (menu "User Agent"))
tell process "Safari"
repeat until name = "1 match" --on safari when you try and find something it will either say "not found"
or "1 match" or something... now i know this line is not correct so i just need help to make it so that if the find bar on safari
keeps returning "not found" then it should repeat the ones below until the find bar displays "1 match"
keystroke "r" using {command down}
keystroke "f" using {command down}
keystroke "164"
end repeat
end if
delay 5
end tell
end tell
the find bar or whatever its called looks something like this when the text is not on the page it will say "not found" like this image here: http://i30.tinypic.com/2hpr8yq.png
sorry if my message is getting long but basically my question now is... how do i make the message that gets displayed in that find bar the variable that determines whether the script should be repeated or stopped if a match or no match is found... let me know if im not making any sense lol.
Similar Messages
-
Using AppleScript to find specific text in mail message?
I'm new to scripting, and I'm a bit lost on this one...
Is there any way to use AppleScript to find a file name from within the body of a mail message so it can be used later in the script?
Specifically, I want to use AppleScript to "read" the content of a mail message and look for a paragraph that says "Filename: MyFileName" so I can set "MyFileName" as a variable. (There will always be a paragraph that begins with "Filename: " in this particular email message.)
This will part of a larger script that uses Fetch to download "MyFileName" from our FTP server.
Thanks in advance for any ideas - I'm struggling with this one.
Andy GillOk, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with aCounter from 1 to count theSelectedMessages
set theMessage to item aCounter of theSelectedMessages
set theContent to content of theMessage
set theWords to every word of theContent
set theFilename to {}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
repeat with thisLoop in theWords
try
if (text item 1 of thisLoop) is "Filename" then
set end of theFilename to (text item 2 of thisLoop)
-- rest of your logic goes here the display is just to show it finds the filename, take it out!
display dialog theFilename ¬
buttons {"OK"}
end if
end try
end repeat
set AppleScript's text item delimiters to tid
end repeat
end perform mail action with messages
end using terms from
Message was edited by: stephen.bradley Typos for the win! -
URGENT : jbo:Row Find action bug ???
Hi,
I am using JDEV 3.2.3 and the data tags to create JSP Master-detail pages.
But very often when I am using the find action of the jbo:Row data tag, the corresponding rows in the detail view is not good (no rows or not all rows !!!).
But if I test my data model with BC4J Tester it is working well !!!
Is there a BUG with the Find Action of jbo:Row Data tag ???
If so how can i correct the bug until the next release of the jbo data tags ???
ThanksJared,
The rowkeyParam seem to be correct since you where able to retrieve a row.
Now the problem seem to be when we try to set the current row to this one.
at oracle.jbo.server.ViewObjectImpl.setCurrentRow(ViewObjectImpl.java:4971)
It might be something simple like the row in the rowkey is not from the same entity as the rowset you are using to find it (deptDs).
Another possibility is the rows are not fetch yet or there are no rows yet in the set.
Try to place a <jbo:RowsetNavigate datasource="deptDS" action="first" /> before your Row tag.
Charles. -
When I open Safari, Finder or Google Chrome (my default browser) they do not displayanywhere on my iMac.
Tthey are minimized somewhere but how can to maximize them.
I can't say for sure this is related to Mavericks but the problem began shortly after dowloading Mavs.
Any suggested fix?Hope the following helps to make things clearer.
When I left click Safari or Google Chrome in my Dock, neither expands. When I then right click wither one in teh Dock, a dialog box pops up which gives me the option to close them, which implies that they are in fact open.
In other words, when I left click on Safari or Chrome in my Dock, nothing visibly changes on my Desktop. Indeed, neither Safari not Chrome are listed as the active window in the menu bar. If I do the same with Finder, at least Finder shows up as active in the menu bar but that's all. Finder itsef is not accessible and so I cannot use it.
On the other hand, I ahve no problem opening up Paralles 9 for Mac to access Windows/Explorer which is what I have done to send this note to teh Apple Communities Forum. Nor do I ahve a problem opening up any of my other programssuch as Office for Mac, etc.
I suspect this may be mavericks related but can't say for sure.
Any help would be much appreciated. Thanks. -
Adobe mentions it cannot find action list
When installing adobe flash it mentions at the end of the install process that it can't find 'action list' does anyone know how to solve this?
https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
-
Is Safari Find function flexible? (Search for inner strings of characters?)
I'm running 10.6.8 with Safari Version 5.1.7 (6534.57.2). I see that when you search a web page using the Safari Find function, you can only search for the beginnings of words, not for character strings within the words. Is it possible to expand the Find function's capability to search for inner strings of characters?
use command F or the edit menus to make the page search box visible - click the magnify/arrow icon at the left side of it - choose "contains" or "starts with".
-
AppleScript error: Finding the Kind of a File
Hello,
i'm trying to build a simple Applescript that transverse a folder and then, acording to the file type, do some action.To find the kind of file I use Finder's Kind Of.
The problem is that the first time I run this script, the "kind of" returns an empty String. The second time it returns ok...
(Note: I'm runing the script in a networked folder, mounted as NFS. I tried with AFP and is the same behaviour). Its possible that result from a spotlight (ou other thing similar) error.
Is there any other option to retrieve a File type/kind ?
My script is similar to:
set lGlobalPath to choose folder with prompt text "Folder to process" without multiple selections allowed
tell application "Finder" to set lOriginalFiles to entire contents of lGlobalPath as alias list
repeat with lOriginalAlias in lOriginalFiles
tell application "Finder" to set lKind to kind of lOriginalAlias
if lKind is "Folder" then
log "Folder" doLog("IGN" & tab & "folder" & tab & lOriginalAlias)
else if (lKind contains "Movie")
log "Movie"
else if (lKind contains "Image") then
log "Image"
else
log "unknown"
end if
end repeatFollowup:
I'm now using:
set lKind to kind of (info for lOriginalAlias)
and It seems to Work just fine -
AppleScript: Safari - Save As Web Archive
The title says it all: Can someone tell me please how - most likely via UI scripting, since I can't see anything in the dictionary - I can get Safari to save the front most document as a Web Archive using AppleScript?
This is one I have recently written that saves all tabs in a window, it remembers the parent folder until next time, and also uses the webarchive ending when Safari is in doubt. You can set properties for whether you like it to overwrite or not. Please look at Macscripter for any updates.
property tlvl : me
# Release 1.0.1
# © 2012 McUsr and put in Public Domain under GPL 1.0
# Please refer to this post: http://macscripter.net/post.php?tid=30892
property shallClose : false # set this to false if you don't want to close the windows, just saving them
property dontOverWriteSavedTabs : false # set this to true if you don't want to overwrite already saved tabs in the folder
script saveTabsInSafariWindowsToFolder
property parent : AppleScript
property scripttitle : "SafariSaveTabs"
on run
if downloadWindowInFront() then return 0 # activates Safari
local script_cache
set script_cache to my storage's scriptCache()
set saveFolder to POSIX path of (getHFSFolder({theMessage:"Choose or create folder to save Safari-tabs in.", hfsPath:DefaultLocation of script_cache as alias}))
if saveFolder = false then return 0 -- we were obviously mistaken, about what we wanted to do.
my storage's saveParenFolderInScriptCache(saveFolder, script_cache)
tell application "Safari"
tell its window 1
local tabc, oldidx
set tabc to count tabs of it
if not tlvl's shallClose then
set oldidx to index of current tab
tell tab tabc to do JavaScript "self.focus()"
end if
local saveCounter
set saveCounter to 1 -- regulates setting of save folder to only first time in Safari.
repeat while tabc > 0
local theUrl, theIdx, theProtocol, alreadyClosed
set {theUrl, theIdx, alreadyClosed} to {URL of its current tab, index of its current tab, false}
if my isntAduplicateTab(theIdx, it) then
set theProtocol to my urlprotocol(theUrl)
if theProtocol is in {"http", "https"} then
# save it
set saveCounter to my saveCurrentTab(saveFolder, saveCounter)
else if theProtocol is "file" then
# make an alias of it
my makeAliasForAFurl(saveFolder, theUrl)
end if
else
if tlvl's shallClose then
close current tab
set alreadyClosed to true
end if
end if
if not alreadyClosed and tlvl's shallClose then
close current tab of it
set tabc to tabc - 1
else if not tlvl's shallClose then
set tabc to tabc - 1
if tabc > 0 then tell tab tabc to do JavaScript "self.focus()"
end if
end repeat
# move forwards
if not tlvl's shallClose then
tell tab oldidx to do JavaScript "self.focus()"
end if
end tell
end tell
end run
to makeAliasForAFurl(destinationFolder, furl)
local ti, tids, thefilePath
set ti to "file://"
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ti}
set thefilePath to text item 2 of furl
set AppleScript's text item delimiters to tids
set theFile to POSIX file thefilePath as alias
set theFolder to POSIX file destinationFolder
tell application "Finder"
make alias at theFolder to theFile
# I don't care if there was one there from before, as it could equally
# be a file with the same name.
end tell
end makeAliasForAFurl
to saveCurrentTab(destinationFolder, timeNumber)
tell application id "sfri" to activate
tell application "System Events"
set UI elements enabled to true
tell process "Safari"
keystroke "s" using {command down}
tell window 1
repeat until exists sheet 1
delay 0.2
end repeat
tell sheet 1
if timeNumber = 1 then -- We'll set the savepath upon first call
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
tell sheet 1
set value of text field 1 to destinationFolder
click button 1
delay 0.1
end tell
end if
keystroke return
delay 0.2
if exists sheet 1 then -- We are being asked if we want to overwrite already saved tab
if dontOverWriteSavedTabs then
keystroke return # if it was already saved. We don't overwrite it
click button 3
else
keystroke tab
keystroke space # we are to overwrite
end if
else
try
set dummy to focused of sheet 1
on error
# click button 1 of panel of application "Safari"
keystroke return
delay 0.2
if exists sheet 1 then -- We are being asked if we want to overwrite already saved tab
if dontOverWriteSavedTabs then
keystroke return # if it was already saved. We don't overwrite it
click button 3
else
keystroke tab
keystroke space # we are to overwrite
end if
end if
end try
end if
end tell
end tell
end tell
end tell
set timeNumber to timeNumber + 1
return timeNumber
end saveCurrentTab
on downloadWindowInFront()
tell application "Safari"
activate
set tabCount to count tabs of its window 1
if tabCount < 1 then
tell application "SystemUIServer" to activate
activate
return true # Downloads window or somethingelse
end if
end tell
return false
end downloadWindowInFront
on isntAduplicateTab(idxOfCurrentTab, theWin)
using terms from application "Safari"
tell theWin
set curTabname to name of tab idxOfCurrentTab
set curTabUrl to URL of tab idxOfCurrentTab
repeat with i from (idxOfCurrentTab - 1) to 1 by -1
if name of tab i = curTabname and URL of tab i = curTabUrl then return false
end repeat
return true
end tell
end using terms from
end isntAduplicateTab
on getHFSFolder(R) -- Returns hfsPathAsText
-- R : {Amessage:theMessage,hfsPath:aStartPath}
local new_path, failed
set failed to false
tell application "SystemUIServer"
activate
repeat while true
try
set new_path to (choose folder with prompt (theMessage of R) default location (hfsPath of R) without invisibles) as text
on error e number n
if n is -128 then
set failed to true
exit repeat
end if
end try
exit repeat
end repeat
end tell
if failed is true then
return false
else
return new_path
end if
end getHFSFolder
on urlprotocol(anUrl)
# returns the protocol of an Url, i.e. http, https, file, localhost etc.
local tids, theProtocol
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "://"}
set theProtocol to text item 1 of anUrl
set AppleScript's text item delimiters to tids
return theProtocol
end urlprotocol
to parentfolder for aPath
local colons, slashes, origDelims
set {colons, slashes} to {false, false}
if (offset of ":" in aPath) > 0 then set colons to true
if (offset of "/" in aPath) > 0 then set slashes to true
if colons and slashes then
return null
else if colons then
set origDelims to ":"
else if slashes then
set origDelims to "/"
else
return null
end if
local tids
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, origDelims}
if aPath = "/" then
-- we return root when we get root
set AppleScript's text item delimiters to tids
return "/"
end if
local theParentFolder
if text -1 of aPath is in {":", "/"} then
set theParentFolder to text items 1 thru -2 of text 1 thru -2 of aPath
else
set theParentFolder to text items 1 thru -2 of aPath
end if
set theParentFolder to theParentFolder as text
if slashes and theParentFolder = "" then set theParentFolder to "/"
-- sets the root path if we got a folder one level below it
if colons and (":" is not in theParentFolder) then set theParentFolder to theParentFolder & ":"
-- we return volumename, if we are given volumename
set AppleScript's text item delimiters to tids
return theParentFolder
end parentfolder
script storage
property cachespath : ((path to library folder from user domain as text) & "caches:" & "net.mcusr." & scripttitle)
on scriptCache()
local script_cache
try
set script_cache to load script alias (my cachespath)
on error
script newScriptCache
property DefaultLocation : (path to desktop folder as text)
# edit any of those with default values
end script
set script_cache to newScriptCache
end try
return script_cache
end scriptCache
to saveScriptCache(theCache)
store script theCache in my cachespath replacing yes
end saveScriptCache
to saveParenFolderInScriptCache(theFolderToSaveIn, script_cache)
local containingFolder
set containingFolder to (parentfolder of saveTabsInSafariWindowsToFolder for theFolderToSaveIn) & "/"
local theLoc
set theLoc to POSIX file containingFolder as alias
set DefaultLocation of script_cache to theLoc
my saveScriptCache(script_cache)
end saveParenFolderInScriptCache
end script
end script
tell saveTabsInSafariWindowsToFolder to run -
Applescript Safari Save Document error
The following applescript command started giving me an error message 3 days ago. I suspect there was a bug in Apple's last OS software update.
tell application "Safari" to save document 1 in file ((path to desktop as string) & "test")
The error I get is "The document “Start New Discussion : Apple Support Communities” could not be saved as “test”. " It doesn't seem to matter what document is currently open in Safari nor the type of document. I first encountered it with a JPEG image. At that time the code was part of a larger script and the file name included ".jpg" but the error occurs with or without an extension.
I get the same error on my Mac Pro, my MacBook Pro and my wife's Mac Mini. I believe all 3 Mac's have the must current OS 10.6 updates.
The larger script in question functioned correctly on July 25, 2011, so this must be recent.
Any ideas?
TIA
Rich CohenI suspect there was a bug in Apple's last OS software update.
I think you're right.
Any ideas?
Maybe you might want to try the following workaround (which doesn't require that you enable access for assistive devices in the Universal Access System Preference pane):
tell application "Finder"
set fileExists to file ((path to desktop as text) & "test") exists
end tell
tell application "Safari"
if not (document 1 exists) then return
activate
end tell
tell application "System Events"
keystroke "s" using {command down}
delay 1 -- might be less
keystroke "test"
keystroke "d" using {command down} -- desktop
keystroke return -- save
if fileExists then
delay 1 -- might be less
keystroke "r" using {command down} -- replace
end if
end tell -
AppleScript that Finds Photos and Copys Created within Week
Hello,
I have three folders where I download photos. Each folder has different types of photos. I'd like to create a new folder that contains the copied most recent photos from my three folders. I was able to do this in workflow, but I'm not sure how to start the AppleScript.
Plus with workflow, it only works when I manually run it. Ideally, I'd like to see the results when I open the recent folder. Someone mentioned a Folder Action, but I can't figure out how to get it to work when the folder is opened.
I feel like i'm missing something fairly simple and i'm too tired to figure it out.
Please help!
Thanks!I remember a script I wrote back in 2005. I had run a KDX-Server and I wanted a folder that contains aliases of my latest uploads. The way the skripts works is a bit ehm... strange since I was only able to create symbolic links using a shell script together with find, and later on theses symbolic links had to be converted to aliases so that kdx could recognize them...
(Find is pretty fast on searching for the latest files)
well, in addition a short manual
--hubionmac.com 07.02.2005
--#################################--Preferences--############################## ###--
property daycount : 4
property depthscanswitch : "off" --(on/off)
property dirnameinaliasname : "off" --(on/off)
global maxfolderdeep, folderkind, destination_folder, currentfoldername, tempfolder
--## Set all working directories
tell application "Finder"
set folderkind to kind of folder 1 of startup disk
try
set aliasfolder to (folder "recentuploadsaliases" of startup disk) as alias
on error
make new folder at startup disk with properties {name:"recentuploadsaliases"}
set aliasfolder to (folder "recentuploadsaliases" of startup disk) as alias
--error "A folder called \"recentuploadsaliases\" has been created at your startup disk."
end try
try
set temp_folder to folder "_temp" of aliasfolder as alias
set tempfolder to POSIX path of temp_folder
on error
make new folder at (aliasfolder as alias) with properties {name:"_temp"}
set temp_folder to folder "_temp" of aliasfolder as alias
set tempfolder to POSIX path of temp_folder
end try
set scangroupfolders to every folder of (aliasfolder as alias)
end tell
--## Now scan every folder
repeat with currentscan_groupfolder in scangroupfolders
tell application "Finder" to set itemname to name of currentscan_groupfolder
if itemname as text ≠ "_temp" then
--## clean the tempdir and the destination folder from aliases and links
tell application "Finder" to set destination_folder to original item of alias file "destination_folder" of currentscan_groupfolder
do shell script "rm -f " & quoted form of (POSIX path of (destination_folder as alias)) & "*"
do shell script "rm -f " & quoted form of tempfolder & "*"
tell application "Finder" to set the_folders to every alias file of currentscan_groupfolder
repeat with the_folder in the_folders
if name of the_folder ≠ "destination_folder" then
tell application "Finder" to set thepath to original item of the_folder
if depthscanswitch = "on" then
set maxfolderdeep to (character 1 of ((name of the_folder) as text)) as integer
else
set maxfolderdeep to 1
end if
tell application "Finder" to set thefolder to original item of (the_folder as alias)
set currentfoldername to (name of thefolder) as text
makesymlinks(thepath)
end if
end repeat
-- ## create aliases of symbolic links at the destination directory
tell application "Finder"
set these_ to every item of temp_folder
repeat with this_ in these_
if dirnameinaliasname = "on" then
set name_01 to name of container of (original item of this_)
set name_00 to name of (original item of this_)
set aliasname to name_00 & " @ " & name_01 as string
make new alias file to ((original item of this_) as alias) with properties {name:aliasname} at destination_folder
else
make new alias file to ((original item of this_) as alias) at destination_folder
end if
end repeat
end tell
end if
end repeat
on makesymlinks(the_folder)
set thepath to POSIX path of (the_folder as alias)
do shell script "find " & quoted form of thepath & " -ctime -" & daycount & " -maxdepth " & maxfolderdeep & " -mindepth " & maxfolderdeep & " -exec ln -s {} " & quoted form of tempfolder & " \\;"
end makesymlinks
Maybe this helps in a way. -
Why can't Safari find this server?
I use gmail to access my email. my daughter recommended me for an American Express Jetblue card that has to be signed up for thru the email they sent me, BUT, Safari message says
I have cleaned the cache, reset Safari and called American Express (they have no idea why this is happening) I can get on their regular site…and al lothers
What now?
Safari can’t find the server.
Safari can’t open the page “http://email.americanexpress.com/a/hBODUZAAQB6FsB8TrbMNsoagO.AQB6FsCL/axp1Safari can’t find the server “email.americanexpress.com”.The IP address for email.americanexpress.com is - 74.127.10.68
At least that's what it resolved to for me. I too get promos through email for them that require you to perform actions through custom web links (email.americanexpress.com) and it works just fine through my GMail account. So it's either an ISP issue (unlikely) or the link got modified by GMail somehow to where it does not work properly.
As Niel suggested, AMEX will need to support this. -
Applescript to run "action" in action wizard
Hi Forum,
using this applescript I m running my "INDEGN" action from action wizard...
the first step is activated through the applescript.. (ie. INDEGN action is correctly picked)
but how to "click next button" to proceed to next steps..
tell application "System Events"
tell application process "Acrobat"
tell application "Adobe Acrobat Pro" to activate
click the menu item "INDEGN" of menu 1 of menu item "Action Wizard" of the menu "File" of menu bar 1 ## here it is not cliking next button.....
click button "Next" of window "Action: INDEGN"
click button "Close" of window "Action: INDEGN"
end tell
end tell
many thanks for the support..Hello Rajinik,
I found your question in the forum and I am exactly in the same situation...
I hace some actions defined in Acrobat X Pro and I would like to execute them just by saving a file in a folder, but it seems something difficult to achieve.
Did you find any help on this or another forum to resolve it?
Searching for some info, i found a website with some info about a way to automatically OCR the pdf pages through theaction wizard, but it didn´t worked in my Mac. Search in Google "OCR This"
Thanks and Regards
Johanet -
Pass neooffice variable to applescript, open finder
i have a spreadsheet in neooffice. there is a column which contains
complete paths and filenames (each cell is a path/filename). i'd like
to be able to click on the filename and have the finder open and
highlight the file in question.
i'm brand new to applescript. have some experience with bash, c,
powershell, batch. i'm starting by trying to write an applescript
that will simply tae a hardcoded path/filename and open finder and
highlight the file. haven't even been able to figure out how to
do this yet. any help is appreciated.
secondly, i would then try to pass a variable to replace the
hardcoded path/filename. the variable would be the path/filename
from the clicked cell.
basic actions, then, would seem to be:
click cell
script runs
script collects variable from cell
script opens finder to path
script highlights filename
any help on how to proceed with this is much appreciated.
thanks,
BabaGThis is complicated somewhat by the fact that NeoOffice doesn't support AppleScript, and appears to have what I consider a bug in that it appends a return to the end of the data in a cell when copied. Nevertheless, this should get you close:
tell application "NeoOffice" to activate
tell application "System Events"
tell application process "NeoOffice"
keystroke "c" using {command down} -- use 'Copy' to get the selected cell content
set filePath to text 1 through -2 of (get the clipboard) -- trim the return off the end!
end tell
end tell
set theFile to POSIX file filePath -- coerce the path to a file reference
tell application "Finder" to reveal theFile -- and select it in the Finder
Note that there's no error checking to ensure that what you copied is a valid path, nor that you only have one cell selected. -
Help with AppleScript as Export Action
I've been trying to get an AppleScript working as an Export Action in Lightroom 3 on OS X (10.5) without success.
The script (modified from one I found):
on open theObjects
repeat with theObject in theObjects
do shell script "/opt/local/bin/mogrify -colorspace Gray " & "'" & (POSIX path of theObject as string) & "'"
end repeat
end open
I've also tried it as:
do shell script "/opt/local/bin/mogrify -colorspace Gray " & (POSIX path of theObject as string)
I've also tried some simpler things just to check if the script is getting called at all, and it doesn't appear to be. Is there something special I need to do to use an AppleScript as an Export Action? It's in the correct folder, and the script name comes up as a selection in the drop-down menu when using a custom Post-Processing option.
Any help or insights appreciated!banacheq wrote:
... It didn't even occur to me to look in "File Format" for converting a script to an application.
Apple sometimes makes things "too" easy. Its like trying to find the salt shaker when its right by your plate...
(I had done it before but had forgotten how)
Glad you got it working.
Rob -
Help Needed: Automator Applescript for Folder Action - Encode Video
Hi !
I have created an Automator Applescript for a Folder Action to do the following:
When a new video file is moved to the target folder (i.e. Download of Vuze is done), automatically launch the Applescript Action that does the followin g(Applescripted):
1) Using "run shell script" and FFMPEG on a UNIX command line, determine Width/Height, Framerate, Bitrate
2) Calculate encoding parameters (slightly reduced bitrate, reduced Aspect etc.)
3) Using "run shell script" with ffmpeg on the command line and the calculated parameters to encode the video file
At the same time, the action is written to a log file so I know if a file is recognized, when encoding started etc.
It works fine if I save this Action as an .app, make an alias on the Desktop and drop video files on it.
It also works fine if I attach the script to a folder as a folder action and drag a video file in there.
However, when I attach the script as a folder action to the Vuze download folder, it encodes only some video files, i.e. if there was a download of 5 files, chances are good that it will not encode 1 or 2 files out of those 5.
If for example a second download finishes while the encoding for the first download is still going on, sometimes the second file starts encoding after the first encode finishes, sometimes it does not, the file does not make the log file at all, i.e. the folder action missed it or the automator action dropped it because it was still encoding. Still, sometimes it happens, sometimes not.
As I need a solution that is 100% accurate, I would like to ask if there are any ideas on how to do this better maybe? As I am not an Applescript Guru, I would need some help to know what works and what doesn't and what the syntax is.
My main idea right now:
Similar to how ffmpegX works with its "process" application, have a second script (as .app) that receives the files to be encoded from the automator action and puts them in a queue, then proceeds to encode this queue while the main automator action is free to receive the next file.
Writing this second app is quite straightforward (a modified version of my current script) but I have some questions I need help with:
1) How do I call another applescript from within an existing applescript that launches the new applescript in a new process?
2) How do I pass parameters to this new applescript?
3) In case of this "Queueing" Idea, once I called the external applescript the first time, how do I make sure when I call next time, that I don't open a second instance of this script but rather pass another queue item to the original instance to be processed?
Or in general: Is there a better way to achieve this automatic encoding solution that I have not thought about?
Alternatively:
Does anyone know how to call the "process" application that comes with the ffmpegX package with the correct parameters to use as a queueing / processing tool?
Thanks!
Joe
Message was edited by: Joe15000
Message was edited by: Joe15000To do this, I created an Automator workflow with an Applescript snippet to change the 'media kind'.
Here is the 'Run Applescript' workflow step code:
on run {input, parameters}
tell application "iTunes"
set video kind of (item 1 of input) to movie
end tell
return input
end run
Prior to this running, I have an 'Import Files into iTunes' workflow step.
You can switch out 'movie' with: 'TV show', 'music video', or anything in ITLibMediaItemMediaKind.
Good luck,
Glenn
Maybe you are looking for
-
Repairing the 17" Studio Display myself - instructions?
I'm looking to replace the backlight inverter on my 17" Studio Display. Does anyone have some easy to follow instructions for doing this?
-
How do I silently connect to a NAS during login?
I would like to connect to a NAS shared automatically and silently at logon. I can connect to a share manually using 'go > connect to server' I have set the login items for the user to include opening a volume on the NAS (this is the only way that I
-
Hello All, Vendor Invoice is cleared with Check payment, but it has exchange rate differences posted during clearing. User wants to reverse the invoice and posted a new invoice. I am unable to cancel the clearing using FBRA as exchange rate differenc
-
Hey all My old g5s memory was full so installed a new internal drive. I have so far partitioned and named it so it is on the desktop because I saw that in a youtube vid. I'm wondering if that was the best thing to do to use it and if so how should I
-
Revision: 8563 Author: [email protected] Date: 2009-07-14 14:47:50 -0700 (Tue, 14 Jul 2009) Log Message: When integrating TLF Build 468, the scrapToPaste() method of PasteOperation needs to be replaced by textScrap.clone(), not just textScrap.