Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Applescript guru help needed...

Applescript guru help needed...
Thread Tools
DAlex
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 07:34 AM
 
First off let me state that I know diddly about writing applescripts so what I'm asking may not be possible

I want to use image capture to download from my camera to a specific folder - no problem I can set this in the app. I want to be able to then get an alert notifying of the folder change and then asking if I want to rename the files and then put them into a new folder, which I can also name.

I know that a folder action will tell me of the change, that a finder script will allow me to change the name but can it all be done in one process/script?

I've been googling to see if there is anything similar but no luck so far.

Any ideas?

Cheers

DAlex
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Aug 20, 2003, 09:38 AM
 
This is all possible. To be able to use Folder Actions- which can detect when there is a file added to a folder as well as other actions, the folder needs to be open. Is this a show stopper?

Craig
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 10:01 AM
 
Originally posted by suthercd:
This is all possible. To be able to use Folder Actions- which can detect when there is a file added to a folder as well as other actions, the folder needs to be open. Is this a show stopper?

Craig
Show stopper? Not sure what you mean. I was hoping that the folder action "add - new item alert.scpt", which opens the folder if you click yes could be modified to include the actions of the finder script "replace text in items names"

Thanks for replying and if you can help it would be very much appreciated.

DAlex
     
Diggory Laycock
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Aug 20, 2003, 11:13 AM
 
Originally posted by DAlex:
Show stopper? Not sure what you mean. I was hoping that the folder action "add - new item alert.scpt", which opens the folder if you click yes could be modified to include the actions of the finder script "replace text in items names"

Thanks for replying and if you can help it would be very much appreciated.

DAlex
Yes it can - that's what scripting is all about.

Just to clarify - when you say you want the script to rename the files - what do you mean? The "replace text in item names" script does a search and replace for text in the file names.

So if the files were called badger01 , badger02 and bigBagder - and you did a search and replace with badger and goat - you will end up with files called: goat01, goat02 and biggoat.
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 12:14 PM
 
Originally posted by Diggory Laycock:
Yes it can - that's what scripting is all about.

Just to clarify - when you say you want the script to rename the files - what do you mean? The "replace text in item names" script does a search and replace for text in the file names.

So if the files were called badger01 , badger02 and bigBagder - and you did a search and replace with badger and goat - you will end up with files called: goat01, goat02 and biggoat.
Sorry, by rename I meant to say to be given the option to rename ie. to change the camera downloads from dscn01.jpg to something more understandable.

I guess the workflow would be: Plug in camera, image capture opens and downloads to folder X - folder action initiates to say there have been changes to folder X, do I want to see the items (yes no) - if yes then the folder opens and then a finder script launches asking if I want to rename the added files - once renamed another script launches asking if I want to put the added files into another folder. I would end up with folder X containing pictures renamed to the event/subject inside of a folder also named after the event/subject.

Phew! I think that is everything

DAlex
     
Developer
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status: Offline
Reply With Quote
Aug 20, 2003, 12:28 PM
 
Code:
on adding folder items to this_folder after receiving these_items tell application "Finder" repeat with i from 1 to the count of these_items set this_file to item i of these_items set the_name to the name of this_file if (the_name contains ".jpg") then display dialog "Name new image:" default answer the_name buttons {"OK"} default button 1 set the_new_name to the text returned of the result if (the_new_name is not the_name) then set the name of this_file to the_new_name end if end if end repeat end tell end adding folder items to
(totally untested)

Save as executable script in Library/Scripts/Folder Action Scripts/ enable folder actions and attach it to the folder Image Capture is saving the images to.

(totally untested)
Nasrudin sat on a river bank when someone shouted to him from the opposite side: "Hey! how do I get across?" "You are across!" Nasrudin shouted back.
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 01:57 PM
 
Originally posted by Developer:
Save as executable script in Library/Scripts/Folder Action Scripts/ enable folder actions and attach it to the folder Image Capture is saving the images to.

(totally untested)
Thank you for writing this, it works! It doesn't quite do what I was thinking of in that each imported image has to be renamed individually (could be a problem if I'm downloading 60+ images) rather than the search and replace method applied to the folder, but it is close! I am very grateful to you for taking the time.

One thing that your script has shown me is how relatively clear the apple acript language is - and how powerful, I think it is time I attempted to learn it.

Thanks again

DAlex
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 02:51 PM
 
try
tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
set the source_folder to path to desktop folder as alias
end try

Ok, that is the first line from the apple supplied "replace text in item names.scpt", which when saved as an application can be launched from imagecapture upon downloading of images to my folder.

But....how can that first line be altered to only apply to a specific folder, in this case one called photos inside the osx pictures folder.

This would acheive the majority of what I;m looking for.

Thanks

DAlex
     
suthercd
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Aug 20, 2003, 02:57 PM
 
The applescript-users mailing list is a great resource. It is very active.

There are also several websites, Macscripter is a good place to find resources.

HTH
Craig
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 03:14 PM
 
Originally posted by suthercd:
The applescript-users mailing list is a great resource. It is very active.

There are also several websites, Macscripter is a good place to find resources.

HTH
Craig
Thanks, I've been to the macscripter site but felt a bit technically lost - I think I'm just going to have to bite the bullet and start learning how to script. Having had a play with a few scripts I can see the power of applescript, now to learn to use it.

Thanks for all the help and suggestions

DAlex
     
Diggory Laycock
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Aug 20, 2003, 03:20 PM
 
very easy to understand tutorial here:

http://www.tandb.com.au/applescript/tutorial/
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 03:24 PM
 
Originally posted by Diggory Laycock:
very easy to understand tutorial here:

http://www.tandb.com.au/applescript/tutorial/
Thank you, an excellent site/resource - well I guess I know what I going to be reading this evening

Cheers

DAlex
     
DAlex  (op)
Registered User
Join Date: Sep 2000
Location: Cardiff, UK
Status: Offline
Reply With Quote
Aug 20, 2003, 07:03 PM
 
I also found this excellent resource:

http://maccentral.macworld.com/featu...criptprimer00/

DAlex
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 12:45 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,