![]() |
Have Applescript, will travel...
So, I'm learning Applescript right now. And I'm quickly finding that the best way to learn is to just get a project and start working on it, especially since I already know Java. Thus, the concepts are there, I just need to learn a new Vocab.
That said, I'm looking for projects. If anyone here has a small script they would like done (no matter how inane), I've got the time right now to give it a go (though I make no guarantee's). It's just a fun and productive way for me to learn a new skill. I especially would appreciate anyone who can give me a project that gives me an excuse to build a stand alone application out of AppleScript. That would be fun...PM me if you're interested. |
How about a script that will create a compressed archive ( Disk Utility dmg ) of a folder when it's dragged onto it, named by reverse date stamp ( ie. 20070802.dmg ) and saved to a pre-defined backup folder (ie. ~/Documents/Backups/ ).
Thanks :) |
Quote:
|
.
Good idea, Fazstp! |
Do you want the destination hard wired, or do you want a field to enter it into? And I'm pretty sure that will be pretty easy to do.
|
i'll take a script like that too...thxs
|
In the spirit of your learning curve, I won't post an answer here, but I will say that Fazstp's proposal is quite doable. I have a very neat way to do the reversed (i.e. sortable) date in plain vanilla AppleScript, but you should look for one yourself.
|
Are you Applescripting Disk Utility or using hdiutil in a shell script? I've done it with hdiutil, but am having trouble if the folder or volume name contains a space. For some reason the POSIX path isn't backslashing the way I think it should.
Edit: Never mind. I forgot about 'quoted form of...' |
Quote:
set P to quoted form of posix path of F works fine with hdiutil in the form of do shell script "whatever " & P |
I am in dire need for an AppleScript that would transfer my Spotlight comments into IPTC so that my 6,000 plus photos will have the information as part of the file and not part of the .DSSTORE file.
This may be a hard one. |
Quote:
|
Quote:
|
Well it seems like fazstp would be a good on to do...if I knew shell commands...which means this project is even better for me because now I get to use shell commands in my script, thus I'll learn even more! ;).
There's a program called DMG Tool that actually turns all of the hdiutil calls into scripts. But the documentation was sooooo poor that I'm going to skip it. As for scripting Disk Utility, it has no library for some stupid reason, so I'm going to have to go with hdiutil. Like I said before, I look forward to it. But, as I said before, don't hold your breath! I'm trying to learn here, it could take a while. Yours... |
Quote:
Reading the comment is: tell app "Finder" to set cmt to comment of an_alias_to_a_commented_file standard IPTC categories include: Caption, Caption_writer, Headline, Instructions, Byline, Byline_Title, Credit, Source, title, unknown1, City, State, Country, reference_, Categories, Supplemental_Categories, unknown2, Keywords, Copyright_notice, _URL, event_, people, itemlist GraphicConverter can set those individually, but be warned that setting overwrites anything already there. |
Quote:
|
:o That makes my earlier question pretty dumb. I had just assumed Disk Utility was scriptable, but using hdiutil would be faster. :o
|
No such thing as a dumb question....Really
|
After learning AS, you can make fully working programs (menus, buttons, windows) in Xcode with AppleScript Studio.
BTW, People don't usually type the abbreviation of AppleScript Studio. |
Quote:
|
Quote:
|
Quote:
Um, out of curiosity, how does one go about doing that? I could see me doing that with Java or even learning object-c to do it. Why would anyone use AppleScript, wouldn't it be considerably slower? |
Yes it's often slower that C, but not slower than Java typically. People do it because they want to write an app that involves a good deal of interaction with other applications and they want easy access to Apple Events.
|
can you make an apple script that transfers money from your bank account to mine?;)
I would look into making apple scripts to automate certain mundane tasks, like burning a CD, or composing an email or anything that would require some sort of manual data entry. |
Quote:
GraphicConverter would be just fine as long as it does not mess with the photo itself. Is that possible? I have both GraphicConverter and the latest Photoshop if that helps. All I want is a batch application that will "Copy Spotlight Comments" then "Paste results in IPTC comments". You would not believe how hard such a thing is to find! |
I wrote a script a while back see this thread on bbs.applescript.net .
It uses GraphicConverter to write IPTC from user input, But is should be very easy to convert it to your needs |
Hi Schneb;
This should do it (try it on a duplicate set, of course): Code:
set F to choose folderCode:
set F to choose file of type {"public.image"} without invisibles with prompt "Choose a single image" |
Thanks NovaScotian, I gave it a try and it did not work. I made sure GraphicsCoverter was running and tried again--nothing. I then changed the application to Adobe Photoshop, and still, no result. Sigh...
|
Quote:
update to the latest version and try again. Also, I finder when i use my script to do this, its best that GC is running before I run the script. |
Quote:
Try this on one of your files and tell me what K is. Perhaps I've got the kinds wrong. Code:
tell application "Finder" to set K to kind of (choose file without invisibles) |
Sorry about that. Definitely not enough input there.
It compiled OK, I ran it, it asked for a folder, I gave it a folder, it ran, but no comments were transferred. No errors. The result of your script is "Adobe Photoshop JPEG file" Can you tell it to just accept whatever it is? I do have a few audio files and movie files, but it can just ignore those. I believe I only have the following in my archive... JPEG, MOV, MP3. About 90% is JPEG. |
Quote:
Code:
set F to choose file of type {"public.image"} without invisibles with prompt "Choose a single image" |
Quote:
"GraphicConverter got an error: An error of type -2 has occurred" I then came to find out that any photo file that did not have any IPTC text written will give the error above. I put in some IPTC text via Photoshop CS and got the following output... {"Emma with Robert, Aunt Mary and others.", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "-1", "", "", "", "", ""} |
I've added Adobe Photoshop JPEG file to the list (only Adobe would stick it that way; jpeg is jpeg)
Code:
set F to choose folder |
I'm still not getting anything to write to the IPTC.
Not sure if GraphicConverter recognizes just iptc as anything. Should there be any kind of other parameter to tell it just where in the iptc--such as "description"? Note: The following only returns the Spotlight Comments of the folder, and not the content of the files therein... Code:
set F to choose folderNote, I changed "set C to comment of F" to "set C to comment of I" and got a better result. The following script gave an error... Code:
set F to choose folder |
Ahh, Schneb; apologies -- a bug. Change the F in the line below to an I
set C to comment of F -- get the comment from the Finder should be set C to comment of I -- get the comment from the Finder |
Yes, as well as the next line, correct?
set C to comment of I -- get the comment from the Finder tell application "GraphicConverter" to set file iptc of I to {C} -- set it with GC It's running without errors, however, the comments are not being written to the IPTC. Does it need a parameter to say "where" in IPTC? I definitely feel bad about hijacking Zalister's post here. I will write up a new question so we can transfer this exchange there. Sorry Zalister!! |
Quote:
If you don't say "where" as in Mark's script, the comment is just the first item in the list. I can't check that because I don't have photoshop. Code:
set Fldr to choose folder |
I have tested this and it works.
Code:
set F to choose folder |
NovaScotian, you are brilliant. It indeed works! I tested it on a folder full of photos and it wrote all my Spotlight comments to the description IPTC, just like I wanted. Now if I ever lose my .DS_Store files, I will not pine because of the loss of Spotlight comments--it is now a part of the photo itself!
Thanks so much for your time on this. Schneb |
More than welcome, Schneb; Sorry it took so long to debug it. :rolleyes:
|
Zalister, have you written a script for fazstp's compressed archive? I'm curious to see if my solution is different from others. :)
|
Sorry no disrespect to NovaScotian who has taught me a lot ;)
But his script in post #37 did not work, that is why I posted a corrected one The reason the script did not work was: Code:
set Fldr to choose folderCode:
set F to choose folderBut with or without the alias list in place, if you use the line: Code:
tell application "GraphicConverter" to set file iptc of (onePic as alias) to {Cmt} -- set it with GCit works. In my script I did it slightly different but it has the same result The other part that will give bad results or not write the IPTC (even though it looks like it has in the event log) is the class of the text. Code:
set Cmt to («class ktxt» of ((comment of onePic as string) as record)) -- get the comment from the Finder |
So several things are clear:
1) Schneb thanked the wrong person: Mark's version was the winner and clearly the one that Schneb must have used. Credit where it is due. :) 2) My script should have read (now thoroughly tested): :rolleyes: Code:
set Fldr to choose folder3) To check the results: Code:
set Fldr to choose folder |
Pardon to all. I neglected to mention that I was heading out of town for a week and would not even get a chance to start to script until I get back. People keep telling me I need to be more forthright about my scheduling... One of these days I'll learn. Sorry again.
That said, I've been looking into learning some of the UNIX commands to get this done, and I'm working with droplets in AppleScript Studio to try and get it done. It will probably take a few days, but the wife is still out of town and I have nothing to do on Friday night so...maybe I'll be done quickly. Who knows. Again, apologies, but I'm back and I'm going to start working on it. |
I uploaded a dmg backup script.
DMG Backup Thanks to cwtnospam for the hdiutil scripting. Sorry Zalister, I had to do some Applescripting for another project and once I got the hdiutil method from cwtnospam it was a short leap to the backup script I originally asked you for. |
Quote:
Again, a big THANK YOU to both Mark Hunte and NovaScotian! |
fazstp -- Don't worry about it. I'm beginning to think I should just figure out a useful script myself and execute on it. These forums don't work at the same glacial pace that I do :).
|
Quote:
(Sorry :o glacier joke) |
No, but every now and then I feel my will to work on scripts evaporating into thin air.
(Two can play at that game ;).) |
| All times are GMT -5. The time now is 01:06 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.