set theFolder to path to desktop
tell application "Finder"
repeat until (count (files of theFolder whose name extension is "mov")) > 0
delay 1
end repeat
end tell
on run {input, parameters}
set ruta to (input as text)
– display dialog (ruta)
tell application “Finder”
activate
repeat until (count (files of input whose name extension is “mov”)) > 0
delay 2
end repeat
end tell
display dialog “¿Parece que ya has generado la movie, se va a entregar la version en avi” with icon caution buttons {“Continuar”}
return input
end run
input variable is a path like: “/Volumes/folder/folder 01 (test)”
this is a applescript in automator
on run{input, parameters}
repeat until fileExists(posix path of (input as string))
delay 0.2
end repeat
display dialog "¿Parece que ya has generado la movie, se va a entregar la version en avi" with icon caution buttons {"Continuar"}
return input
end run
on fileExists(posixFile)
return not ((do shell script "test -e " & quoted form of posixFile & " ;echo $?") as integer) as boolean
end fileExists
set ThePath to "/Volumes/folder"
return {POSIX file ThePath, (POSIX file ThePath) as string}
display dialog (ThePath)
i get path converted well with :
but if i try to get a input value like this
on run {input, parameters}
set ThePath to input
return {POSIX file ThePath, (POSIX file ThePath) as string}
display dialog (ThePath)
i get a error… i dont know what?? missing quotes " "… i dont calling value in input well, input only have a value like /Volumes/folder in it, what are im doing wrong?
The reason I did the conversion when calling the handler is so I don’t need another variable (overhead) and also the variable input won’t get affected.
in an Automator action input is a list of objects in most cases
if the list contains only one item, coercing to text flattens the list.
If the list contains more than one item, the script will fail.
Try this, it takes the first item of the list and coerces to HFS path
on run {input, parameters}
set inputHFSPath to POSIX file (item 1 of input) as text
tell application "Finder"
repeat until (count (files of folder inputHFSPath whose name extension is "mov")) > 0
delay 1
end repeat
end tell
return input
end run
stored (item 1 of input) is “/Volumes/folder01” and dont work.
if i change manually the variable to “Volumes/folder01” without first slash then the POSIX conversion is OK, is automator that store this value in input, how i can do to run ok?
set inputHFSPath to POSIX file “/Volumes/folder01” as text ----> return :folder01
set inputHFSPath to POSIX file “Volumes/folder01” as text ----> return :Volumes:folder01
set inputHFSpath to POSIX file (item 1 of input) as text ----> return ERROR if (item 1 of input = /Volumes/folder01)
set inputHFSpath to POSIX file (item 1 of input) as text ----> return :Volumes:folder01 if (item 1 of input = Volumes/folder01)
/Volumes/folder01 is an example of a mounted network volume, the actual path is longer, but im sure that exist. If i remove the first slash the conversion is ok… i can send you the automator workflow if you want.
this is my error and try
set inputHFSPath to POSIX file “/Volumes/folder01” as text ----> return :folder01
set inputHFSPath to POSIX file “Volumes/folder01” as text ----> return :Volumes:folder01
set inputHFSpath to POSIX file (item 1 of input) as text ----> return ERROR if (item 1 of input = /Volumes/folder01)
set inputHFSpath to POSIX file (item 1 of input) as text ----> return :Volumes:folder01 if (item 1 of input = Volumes/folder01)
1º New folder
2º set value of variable (this give you a new variable with /Volumes/thePath/newfolder) (problematicpath is the name of variable)
------- ignore input data
3º get value of variable (problematicpath)
4º run applescript
on run {input, parameters}
set inputHFSPath to POSIX file (item 1 of input) as text
return inputHFSPath
this workflow fail in 4º step, but if manually modify the content of variable “problematicpath” and remove the first slash, the result seems be ok “:Volumes:thePath:newfolder”
OK, the problem is, the variable contains a list of aliases, not POSIX paths
The alias can be used directly
on run {input, parameters}
set inputAlias to (item 1 of input)
tell application "Finder"
repeat until (count (files of inputAlias whose name extension is "mov")) > 0
delay 1
end repeat
end tell
return input
end run
thanks @Yvan Koenig,
I tried, but ended up in an infinite loop.
ok, i’ll explain better, i’m running a shell command that informs me of the connected external devices, like pendrives.
if he verifies that he has an external device connected he takes his name and inserts it in a Label, but what happens is that if I have 2 external devices he inserts the same name for both.
I’m sorry if I wasn’t clear.
Here is how you can check concrete USB devices is connected or not, and if they are connected then add to labels list (simple and fast way, without getting detailed info for them):
set usbNames to {"someNot_HARD_DISK", "myRemovableUSB_1", "myRemovableUSB_2"}
set allDisks to paragraphs of (do shell script "cd /Volumes; ls")
set USB_labels to {}
repeat with i from 1 to count usbNames
set usbName to item i of usbNames
if allDisks contains usbName then set end of USB_labels to usbName
end repeat
return USB_labels