Re: How do I get a script to ask me the number of times to repeat?
Re: How do I get a script to ask me the number of times to repeat?
- Subject: Re: How do I get a script to ask me the number of times to repeat?
- From: John Stewart <email@hidden>
- Date: Thu, 24 Feb 2005 18:44:45 -0500
On 2/24/05 at 5:17 PM, the entity Simon Kidd spoke thusly
>I didn't do a very good job of explaining myself. The files are from
>experiments measuring fly activity. Each file in the folder
>represents one fly and there are several different fly strains
>intermixed with each other. I need to move all the files representing
>one strain into their own folder. The way my data is organised I need
>to choose which file to copy and then subsequently copy every nth
>one. I then choose the next file and repeat the process until each
>file in the folder has been copied to a new folder. I took bits of
>your script and came up with:
>------------------
>set theDestinationFolder to choose folder with prompt "Select a
>destination folder:"
>set nR to text returned of (display dialog "Please enter \"nR\":"
>default answer "") -- the number of files in the folder divided by
>the number of strains
>set nP to text returned of (display dialog "Please enter \"nP\":"
>default answer "") ---the number of strains
>tell application "System Events"
> tell process "Finder"
> activate
> repeat with i from 1 to nR
> copy selection to theDestinationFolder
> repeat with j from 1 to nP
> key code 125 -- down arrow Key
> end repeat
> end repeat
> end tell
>end tell
>------------------------
>
>It fails at "copy selection to theDestinationFolder"
That's because -
1) You can't copy a selection object to a folder, only the selection objects's contents
2) Copy isn't the correct command for moving/duplicating files and folders. This calls for "move" or "duplicate".
Here's a tested example -
set theDestinationFolder to path to trash
tell application "Finder"
activate
move (every item of (get selection)) to theDestinationFolder
end tell
I'm curious as to why you are trying to implement this with GUI scripting. Is there nothing in the file names or extensions to differentiate by strain? If not then how do you determine which one to click on to start the process? If there is a difference then you would be better off to use that difference than GUI scripting. What's going to happen if you accidentally click a file (and you will eventually) while the script is executing. Please post some example filenames for us, maybe we can see a more efficient or bulletproof method.
JBS
--
He who laughs last, thinks slowest.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden