• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript-Users Digest, Vol 12, Issue 341
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Users Digest, Vol 12, Issue 341


  • Subject: Re: AppleScript-Users Digest, Vol 12, Issue 341
  • From: Die Fledermaus <email@hidden>
  • Date: Thu, 30 Jul 2015 15:01:49 -0400

Mark,

That is exactly what I am trying to do is use the on idle Handler with a script that is saved as a stay open application.

set nameslist to {} is what I had originally and when I run the app I get the variable nameslist comes back as undefined.


Also I am going through all of this because when I add a script to the configure folder actions setup the script never runs now that I have upgraded to 10.0.4 under 10.9.x the folder actions just worked.


Thanks for the input so far I did add the return delay which I was missing.


On Thu, Jul 30, 2015 at 1:38 PM, <email@hidden> wrote:
Send AppleScript-Users mailing list submissions to
        email@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.apple.com/mailman/listinfo/applescript-users
or, via email, send a message with subject or body 'help' to
        email@hidden

You can reach the person managing the list at
        email@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AppleScript-Users digest..."


Today's Topics:

   1. variables within idle (Die Fledermaus)
   2. Re: variables within idle (Mark Hunte)
   3. Re: variables within idle (Deivy Petrescu)
   4. Re: variables within idle (Yvan KOENIG)


----------------------------------------------------------------------

Message: 1
Date: Thu, 30 Jul 2015 12:13:12 -0400
From: Die Fledermaus <email@hidden>
To: email@hidden
Subject: variables within idle
Message-ID:
        <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"

Folks,

I have a script which watches a folder and moves the files based on the
activity of one of the folders. The problem comes when I run this script
with idle the variable nameslist comes back as undefined when it runs. if I
take out the idles and just loop it or run it once I do not get the error.
I have tried setting the nameslist variable as a global and that was the
same result.

What am I missing when it comes to idles and this variable. The other
variable set to global works without a hitch. I am running this on a
10.10.4 machine.

*global* nameslist

*global* theWatchedFolder

set nameslist to " "

*set* theWatchedFolder *to* "Macintosh
HD:Users:ifbell:Desktop:videofinished" *as* *string*

*on* *idle*

*tell* *application* "Finder"

*set* folderFiles *to* (*every* *file* *in* *the* *folder* theWatchedFolder
*whose* name extension *is* "mp4")

*if* folderFiles *is* *equal to* {} *then* *return*

*repeat* *with* currentFile *in* folderFiles

*set* currentFileName *to* (*the* name *of* currentFile)

#display alert currentFileName

*copy* currentFileName *to* *the* *end* *of* *items* *in* nameslist

*end* *repeat*

*end* *tell*

#display alert listOfNames

*tell* *application* "Finder"

*set* AppleScript's text item delimiters *to* "."

*repeat* *with* n *from* 1 *to* *count* *of* nameslist

*try*

*copy* (*item* n *of* nameslist) *to* fileName

*set* {finname, nameExt} *to* {*text* 1 *thru* *text item* -2, *text item*
-1} *of* fileName

*display alert* finname giving up after 10

*set* fileloc *to* "/Users/user/Desktop/videoTBP/" & finname & ".mov" *as*
*string*

*set* finloc *to* "/Users/user/Desktop/videoprocessed/"

#display alert fileloc

*do shell script* "mv " & quoted form *of* fileloc & " " & quoted form *of*
finloc & ""

*on* *error* errTxt number errNum

*display notification* finname & " has been moved"

*end* *try*

*end* *repeat*

*end* *tell*

 *end* *idle*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20150730/26cf0d5e/attachment.html>

------------------------------

Message: 2
Date: Thu, 30 Jul 2015 17:49:59 +0100
From: Mark Hunte <email@hidden>
To: email@hidden
Subject: Re: variables within idle
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"

An on idle  requirers a return value as it needs to know how long to idle for.

at the end of the Handler add a return with an int value.
i.e


return 30


30 being seconds.

The  on idle Handler is intended to be used with a script that is saved as a stay open application.




> On 30 Jul 2015, at 17:13, Die Fledermaus <email@hidden> wrote:
>
> Folks,
>
> I have a script which watches a folder and moves the files based on the activity of one of the folders. The problem comes when I run this script with idle the variable nameslist comes back as undefined when it runs. if I take out the idles and just loop it or run it once I do not get the error. I have tried setting the nameslist variable as a global and that was the same result.
>
> What am I missing when it comes to idles and this variable. The other variable set to global works without a hitch. I am running this on a 10.10.4 machine.
>
> global nameslist
> global theWatchedFolder
> set nameslist to " "
> set theWatchedFolder to "Macintosh HD:Users:ifbell:Desktop:videofinished" as string
> on idle
>       tell application "Finder"
>               set folderFiles to (every file in the folder theWatchedFolder whose name extension is "mp4")
>               if folderFiles is equal to {} then return
>               repeat with currentFile in folderFiles
>                       set currentFileName to (the name of currentFile)
>                       #display alert currentFileName
>                       copy currentFileName to the end of items in nameslist
>               end repeat
>       end tell
>       #display alert listOfNames
>       tell application "Finder"
>               set AppleScript's text item delimiters to "."
>               repeat with n from 1 to count of nameslist
>                       try
>                               copy (item n of nameslist) to fileName
>                               set {finname, nameExt} to {text 1 thru text item -2, text item -1} of fileName
>                               display alert finname giving up after 10
>                               set fileloc to "/Users/user/Desktop/videoTBP/" & finname & ".mov" as string
>                               set finloc to "/Users/user/Desktop/videoprocessed/"
>                               #display alert fileloc
>                               do shell script "mv " & quoted form of fileloc & " " & quoted form of finloc & ""
>                       on error errTxt number errNum
>                               display notification finname & " has been moved"
>                       end try
>               end repeat
>       end tell
>
> end idle
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20150730/8bc32c9b/attachment.html>

------------------------------

Message: 3
Date: Thu, 30 Jul 2015 13:31:42 -0400
From: Deivy Petrescu <email@hidden>
To: AppleScript Users <email@hidden>
Subject: Re: variables within idle
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset=utf-8


> On Jul 30, 2015, at 12:13 , Die Fledermaus <email@hidden> wrote:
>
> Folks,
>
> I have a script which watches a folder and moves the files based on the activity of one of the folders. The problem comes when I run this script with idle the variable nameslist comes back as undefined when it runs. if I take out the idles and just loop it or run it once I do not get the error. I have tried setting the nameslist variable as a global and that was the same result.
>
> What am I missing when it comes to idles and this variable. The other variable set to global works without a hitch. I am running this on a 10.10.4 machine.
>
> global nameslist
> global theWatchedFolder
> set nameslist to " "
> set theWatchedFolder to "Macintosh HD:Users:ifbell:Desktop:videofinished" as string
> on idle
>       tell application "Finder"
>               set folderFiles to (every file in the folder theWatchedFolder whose name extension is "mp4")
>               if folderFiles is equal to {} then return
>               repeat with currentFile in folderFiles
>                       set currentFileName to (the name of currentFile)
>                       #display alert currentFileName
>                       copy currentFileName to the end of items in nameslist
>               end repeat
>       end tell
>       #display alert listOfNames
>       tell application "Finder"
>               set AppleScript's text item delimiters to "."
>               repeat with n from 1 to count of nameslist
>                       try
>                               copy (item n of nameslist) to fileName
>                               set {finname, nameExt} to {text 1 thru text item -2, text item -1} of fileName
>                               display alert finname giving up after 10
>                               set fileloc to "/Users/user/Desktop/videoTBP/" & finname & ".mov" as string
>                               set finloc to "/Users/user/Desktop/videoprocessed/"
>                               #display alert fileloc
>                               do shell script "mv " & quoted form of fileloc & " " & quoted form of finloc & ""
>                       on error errTxt number errNum
>                               display notification finname & " has been moved"
>                       end try
>               end repeat
>       end tell
>
> end idle
>

Mark replied with a major error, there is no  “return n".
But also
nameslist  is a string but you want to add items to it as if it was a list.
nameslist should be a list.

finname, is text item -2 of fileName . No need to use text 1 thru...
Using

set  WatchedFolder to "Macintosh HD:Users:if bell:Desktop:videofinished"

makes this script attached to your current computer, if you use 'path to “desk” ‘ it becomes a bit more flexible.

My 2cents

Deivy Petrescu






------------------------------

Message: 4
Date: Thu, 30 Jul 2015 19:38:00 +0200
From: Yvan KOENIG <email@hidden>
To: liste AppleScript US <email@hidden>
Subject: Re: variables within idle
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="utf-8"


> Le 30/07/2015 à 19:31, Deivy Petrescu <email@hidden> a écrit :
>
>
>> On Jul 30, 2015, at 12:13 , Die Fledermaus <email@hidden> wrote:
>>
>> Folks,
>>
>> I have a script which watches a folder and moves the files based on the activity of one of the folders. The problem comes when I run this script with idle the variable nameslist comes back as undefined when it runs. if I take out the idles and just loop it or run it once I do not get the error. I have tried setting the nameslist variable as a global and that was the same result.
>>
>> What am I missing when it comes to idles and this variable. The other variable set to global works without a hitch. I am running this on a 10.10.4 machine.
>>
>> global nameslist
>> global theWatchedFolder
>> set nameslist to " "
>> set theWatchedFolder to "Macintosh HD:Users:ifbell:Desktop:videofinished" as string
>> on idle
>>      tell application "Finder"
>>              set folderFiles to (every file in the folder theWatchedFolder whose name extension is "mp4")
>>              if folderFiles is equal to {} then return
>>              repeat with currentFile in folderFiles
>>                      set currentFileName to (the name of currentFile)
>>                      #display alert currentFileName
>>                      copy currentFileName to the end of items in nameslist
>>              end repeat
>>      end tell
>>      #display alert listOfNames
>>      tell application "Finder"
>>              set AppleScript's text item delimiters to "."
>>              repeat with n from 1 to count of nameslist
>>                      try
>>                              copy (item n of nameslist) to fileName
>>                              set {finname, nameExt} to {text 1 thru text item -2, text item -1} of fileName
>>                              display alert finname giving up after 10
>>                              set fileloc to "/Users/user/Desktop/videoTBP/" & finname & ".mov" as string
>>                              set finloc to "/Users/user/Desktop/videoprocessed/"
>>                              #display alert fileloc
>>                              do shell script "mv " & quoted form of fileloc & " " & quoted form of finloc & ""
>>                      on error errTxt number errNum
>>                              display notification finname & " has been moved"
>>                      end try
>>              end repeat
>>      end tell
>>
>> end idle
>>
>
> Mark replied with a major error, there is no  “return n".
> But also
> nameslist  is a string but you want to add items to it as if it was a list.
> nameslist should be a list.
>
> finname, is text item -2 of fileName . No need to use text 1 thru...
> Using
>
> set  WatchedFolder to "Macintosh HD:Users:if bell:Desktop:videofinished"
>
> makes this script attached to your current computer, if you use 'path to “desk” ‘ it becomes a bit more flexible.
>
> My 2cents
>
> Deivy Petrescu
>

My 2 €

Hello Deivy,
it seems that you read too fast Mark's message.

The embedded script is the asker's one.

Mark clearly urged the asker to insert :
at the end of the Handler add a return with an int value.


Yvan KOENIG (VALLAURIS, France) jeudi 30 juillet 2015 19:37:25






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.apple.com/mailman/private/applescript-users/attachments/20150730/93335aeb/attachment.html>

------------------------------

_______________________________________________
AppleScript-Users mailing list
email@hidden
https://lists.apple.com/mailman/listinfo/applescript-users

End of AppleScript-Users Digest, Vol 12, Issue 341
**************************************************

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: variables within idle
  • Next by Date: Open Safari in fullscreen and hide toolbar script
  • Previous by thread: Re: variables within idle
  • Next by thread: Open Safari in fullscreen and hide toolbar script
  • Index(es):
    • Date
    • Thread