• 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: Deivy Petrescu <email@hidden>
  • Date: Thu, 30 Jul 2015 13:31:42 -0400

> 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




 _______________________________________________
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


  • Follow-Ups:
    • Re: variables within idle
      • From: Yvan KOENIG <email@hidden>
References: 
 >variables within idle (From: Die Fledermaus <email@hidden>)

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