• 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: variables within idle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variables within idle


  • Subject: Re: variables within idle
  • From: Mark Hunte <email@hidden>
  • Date: Thu, 30 Jul 2015 17:49:59 +0100

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
References: 
 >variables within idle (From: Die Fledermaus <email@hidden>)

  • Prev by Date: variables within idle
  • Next by Date: Re: variables within idle
  • Previous by thread: variables within idle
  • Next by thread: Re: variables within idle
  • Index(es):
    • Date
    • Thread