image
image

Go Back   macosx.com > Scripts > Apple Scripts

Reply
 
LinkBack Thread Tools
  #9  
Old February 21st, 2009, 02:42 PM
Registered User
 
Join Date: Feb 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ejang is on a distinguished road
awesome

thank you so much!
I'm just curious, but how would I configure the file to duplicate itself to other folders?
Reply With Quote
  #10  
Old February 21st, 2009, 03:47 PM
Registered User
 
Join Date: Feb 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ejang is on a distinguished road
Actually, instead of bugging you repeatedly for this information, do you know where I can find a guide to the script language in layman's terms?
Thanks!
Reply With Quote
  #11  
Old February 21st, 2009, 04:12 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,682
Thanks: 6
Thanked 53 Times in 48 Posts
Mikuro will become famous soon enough
Most scriptable applications contain some built-in documentation of their scripting features. In Script Editor, go to File > Open Dictionary, and then choose the application you want to script. In this case it would be the Finder, which is located at /System/Library/CoreServices/Finder.app

On a related note, I wrote an AppleScript to make opening the Finder's scripting dictionary (which is something frequently need) easier:
Code:
tell application "Script Editor"
	activate
	open POSIX file "/System/Library/CoreServices/Finder.app"
end tell
In the Finder's dictionary, you'll see the duplicate command, which has some optional parameters, including the to parameter. So "duplicate (the path to me) to the desktop" would work, for example.

Apple's AppleScript Language Guide is useful, but it's not a tutorial or a quick start guide. It's really about the more arcane aspects of AppleScript. Your best bet is probably to look through the scripting dictionaries of the apps you're interested it and Google around for examples and tutorials when you get stuck.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
The Following User Says Thank You to Mikuro For This Useful Post:
macbri (February 22nd, 2009)
  #12  
Old February 21st, 2009, 06:11 PM
Registered User
 
Join Date: Feb 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ejang is on a distinguished road
Great!
Thanks for the shortcut script.
I'll be looking into that

In the meantime, I was wondering if it is possible to embed photos, icons, etc. into the application for exporting via email? I know that this might take some java programming as well, but is it possible to bundle some photos with the app so that the script can access it on a different computer?

Thanks
Reply With Quote
  #13  
Old February 22nd, 2009, 10:12 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 12,671
Thanks: 7
Thanked 383 Times in 365 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
Sure, put all the images in a folder, along with the script, then send the whole folder out as a package. Zip it up to safe some bandwidth.

If you want to create a single, double-clickable application that has all the resources include (images, icons, etc.), then I believe you're looking at creating a native Mac OS X application with XCode. I do not believe AppleScript has this capability, though I'm not experienced enough with it to say definitely one way or another.
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 18Mb/2Mb
http://www.jeffhoppe.com
Reply With Quote
  #14  
Old February 22nd, 2009, 07:53 PM
Registered User
 
Join Date: Feb 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ejang is on a distinguished road
Hi,
Thanks for the tip! I guess that makes sense, since scripts are designed to work with files and applications already present on the computer.

Thanks to Miruko, My friends and I did some experimenting with the code provided earlier that duplicates the application some number of times when opened. However, we found that it wasn't annoying enough, since it only occupies one process for every open copy of itself. Therefore, we figured that if we somehow made the program so that it could select and open the copies of itself ONLY after a given amount of time, it can lag up more disk space (again, this is just for fun, not for malicious purposes).

I figured that the modification should involve adding a timeout clause and repeat clause to make the application select after a certain number of copies is made, e.g. 5.

For example, this is what I want to happen after the script runs

click on app.
app duplicates itself 5 times
app selects itself and all 5 copies
app opens all selected programs
repeats

Thanks for helping me- I'm really a computer noob D:

tell application "Finder"
repeat with i from 1 to 100
duplicate (the path to me)
delay 1
end repeat
end tell
Reply With Quote
  #15  
Old February 27th, 2009, 09:34 PM
Registered User
 
Join Date: Feb 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
ejang is on a distinguished road
Hi, I have spent the last week doing some research on my script: I think it works pretty well:
What it does is it enables GUI modifying, dims the screen, mutes the audio, and then proceeds to duplicate itself.

As for the duplicating process, this is what I have.

tell application "Finder"

tell application "Finder"

repeat with i from 1 to 5
repeat with i from 1 to 5
duplicate (the path to me)
end repeat
*(code for selecting the copies of itself need to go here)
open the selection
end repeat
end tell

I'm not sure how to specifically target those new files.

Once again, sorry for my incompetence.
Reply With Quote
  #16  
Old February 27th, 2009, 11:03 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,682
Thanks: 6
Thanked 53 Times in 48 Posts
Mikuro will become famous soon enough
The duplicate command returns a reference to the new copy. So you just need to store it somewhere.

Try this:
Code:
tell application "Finder"
	set file_list to {the path to me}
	repeat with i from 1 to 5
		set file_list to file_list & {(duplicate file_list)}
	end repeat
end tell
Curly braces are how you make with lists in AppleScript. So first you make a list with one object, then you duplicate that list and append to it. Repeat as desired.

The result is 32 copies of the script, since it doubles the number 5 times over (2^5=32).
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
Reply

Bookmarks

Tags
applescript, duplicate, finder, script, timestamp

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 11:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.