image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old May 13th, 2003, 02:02 AM
Jasoco's Avatar
Video Gamer/Collector
 
Join Date: Jun 2001
Location: Doylestown PA
Posts: 499
Thanks: 0
Thanked 0 Times in 0 Posts
Jasoco is on a distinguished road
A script. A script for fun I say. Help me write it.

I would like to write a script. Either AppleScript or a Shell Script. Whichever is more convenient. That will be run at login.

What it will do is randomly pick a file from a specified folder, copy it to a certain directory and rename it to a certain name.

To clarify, it will pick a JPG file from a folder of JPG's at random, and copy it to the "Desktop Pictures" folder and rename it "Aqua Blue.jpg". What this will do is every time I log out, I will have a different login desktop picture.

I'd probably use AppleScript but I'd be calling Shell commands from it for stuff like the copy and rename part. All I need to know basically is how do I randomly pick a file via AppleScript or the such?

This Script will only run once per login then quit when it's done obviously. I just need the one critical part. The file selection.

I wanna do it all without having to have the script open folders and select files. I want it all in the background at the beginning of my session. One time thing.

Thanks.
__________________
Confucious Say: Jasoco, change your gosh darn SIGNATURE! it's been like that forever!
Never disobey Confucious.

Jasoco.net - GeekPub Forums
Reply With Quote
  #2  
Old May 13th, 2003, 07:44 AM
Some guy
 
Join Date: Sep 2001
Location: England
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
goynang is on a distinguished road
Erm - what version of OS X are you running?

You can do this in the prefs on Jaguar - you can set how often the bg image rotates - from once every 5secs (!) to once per login.

Is that what you want?
__________________

PowerMac G5 Dual 2ghz + PowerMac G3 300mhz + iBook 800mhz + 15gb iPod + OS X 10.4.x + Me = Happy
Reply With Quote
  #3  
Old May 13th, 2003, 08:14 AM
dlloyd's Avatar
Official Pianist
 
Join Date: Dec 2002
Location: At a keyboard. One or the other.
Posts: 2,978
Thanks: 0
Thanked 0 Times in 0 Posts
dlloyd is on a distinguished road
If you want to use AppleScript, that would be simple, wouldn't it? Just record it! Oooohh, I forgot about that 'random' part... hmmmm
__________________
< Also Known As aeromusek in places >

< PowerBook | 1.67GHz | 1024MB RAM | 120GB | 17" High Res >
< iPod | 20GB | 3rd gen >


"the show must go on" - the artists of the world
Reply With Quote
  #4  
Old May 13th, 2003, 02:08 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
well, from a shell script point of view:

set num_files = `ls | wc -l`
set the_file = `jot -r 1 1 ${num_files}`
set the_file_name = `ls | sed -n ${the_file}p`
ln -s ${the_file_name} "Desktop Pictures/Aqua Blue.jpg"

would do it
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #5  
Old May 13th, 2003, 03:42 PM
Jasoco's Avatar
Video Gamer/Collector
 
Join Date: Jun 2001
Location: Doylestown PA
Posts: 499
Thanks: 0
Thanked 0 Times in 0 Posts
Jasoco is on a distinguished road
NO NO NO. Goynag. The LOGIN screen. Not the Desktop! I already have my desktop rotating. I want the Login to do it too and I wanted to do it in a fun way. So I wanna make a script. Hone my scripting skillz.

I just need to be able to randomly choose a file at random. Randomly. That's the only part I need to know.

How do I create a Shell Script, scruffy? Just make a file with the text? What do I do? You can give me code, but I need to know where to put it. And can I call it from AppleScript? Thanks.
__________________
Confucious Say: Jasoco, change your gosh darn SIGNATURE! it's been like that forever!
Never disobey Confucious.

Jasoco.net - GeekPub Forums
Reply With Quote
  #6  
Old May 13th, 2003, 08:00 PM
Darkshadow's Avatar
wandering shadow
 
Join Date: Jul 2001
Location: DE, USA
Posts: 1,532
Thanks: 0
Thanked 0 Times in 0 Posts
Darkshadow is on a distinguished road
Well, the shell scripts are easy to make, but you can't have them running automatically at login via the login items, so an Applescript would probably be easier to do.

Well, you could make the shell script then write an applescript to run that shell script, then you could have that applescript run when you log in, but that seems overkill to me.
__________________
I am but a lonely shadow,
Doomed forever to roam and wander.
But if you allow me to pause before I must go,
I'll spin you tales of mystery and wonder.


Site: Night Productions
Reply With Quote
  #7  
Old May 13th, 2003, 08:07 PM
wiz wiz is offline
Registered User
 
Join Date: Jul 2002
Location: Sol
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
wiz is on a distinguished road
no you can make it run automatically at login via login items!!

i read it somewhere. it is possible.
Reply With Quote
  #8  
Old May 13th, 2003, 10:58 PM
Jasoco's Avatar
Video Gamer/Collector
 
Join Date: Jun 2001
Location: Doylestown PA
Posts: 499
Thanks: 0
Thanked 0 Times in 0 Posts
Jasoco is on a distinguished road
Either way, what do I use to create the shell script? Where do I save it and how do I call it from AppleScript, if it can't be run at login? If it can, even better.

I just need to know how to create the script. Pico or something?
__________________
Confucious Say: Jasoco, change your gosh darn SIGNATURE! it's been like that forever!
Never disobey Confucious.

Jasoco.net - GeekPub Forums
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[HOWTO] - Use niutil gatorparrots HOWTO & FAQs 6 December 10th, 2002 04:24 PM
Proper way to write and execute a terminal script? michaelsanford Unix & X11 2 November 8th, 2002 08:24 AM
Getting a CGI script to work locally on my Mac simX Mac OS X System & Mac Software 11 July 12th, 2002 02:43 PM
HOW TO STOP SPAM -- join the fight! GadgetLover Apple News, Rumors & Discussion 11 April 11th, 2002 03:52 PM
AppleScript front end to a shell script? meancode Mac OS X System & Mac Software 0 March 17th, 2002 09:25 PM


All times are GMT -5. The time now is 11:28 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.