Keep auto-timeout Transmit connections alive
I use a shared host which unfortunately, due to circumstances outside my control, terminates my Transmit FTP/SQL sessions after 15 minutes of idleness. Good for processor cycles, poor for my sanity, especially during intensive coding/research sessions. After gleaning the internet for a solution and finding none which worked, I decided to whip up my own. Copy and paste the following code into Script Editor, and save it as an application with the 'stay open' option checked:repeat tell application "Transmit" tell document 1 tell current session refresh list their stuff files end tell end tell end tell delay (60)end repeatIf anyone wants to follow up this with a touch of AppleScript that cycles through every connection, that would be great. This is my first AppleScript project, so woot for me!
published on Thursday, the 23. October 2008, macosxhints
Batch convert Word files to PDFs via Pages
This recent hint on automating print to PDF via Pages and AppleScript gave me the impetus to write an AppleScript for batch converting Word (or any other files that Pages can open) to PDF files (or any format that Pages can export to). Here's the script:(* Drag and drop batch conversion of Word docs to PDF files using Pages*)on open filist repeat with lvar in filist tell application "Finder" set thename to name of lvar end tell set nuname to text 1 thru text item -5 of thename tell application "Pages" activate set filname to (path to desktop folder as text) & nuname & ".pdf" ...
published on Monday, the 20. October 2008, macosxhints
Dupin 1.4 supports Genius playlists, more preferences
Doug's AppleScripts for iTunes has released Dupin 1.4, the latest version of its iTunes duplicate file manager. Genius playlists are now recognized, and a "Refresh Playlist Popup" toolbar button and menu option. Users can choose to limit the number of duplicates that are detecting during each session, or toggle between deleting files or moving them to trash. A date formatting issue has been fixed,...
published on Wednesday, the 24. September 2008, macintosh-news-network
Start playing partially downloaded videos in VLC
I frequently download video files from a web server, and would like to start watching them before the download completes -- VLC, for one, can start playing a video while Safari downloads it. This AppleScript automates that task. Simply select the .download file in the Finder and run the script. You'll probably want to save this script as an Application Bundle: on run tell application "Finder" copy selection to fileName0 end tell set fileName to fileName0 as string if fileName ends with ".download" then set AppleScript's text item delimiters to ":" set listNames to text items of fileName set AppleScript's text item delimiters to "" set baseName to last item of ...
published on Thursday, the 6. March 2008, macosxhints
A script to pick a random login window background
I really this older hint, on how to change the login window background by telling the system to look for the image in another location, but I want to suggest a small variation of it. I like to constantly change my backgrounds. I have a directory with a bunch of background pictures, so I wrote a simple AppleScript which takes a random file from this directory and saves it as the picture used as the login window background. Mine is named myloginwindow.jpg, and it sits in my Public folder. tell application "Finder" set theList to files of folder "wallpaper" of startup disk set theNum to random number from 1 to (count theList) with seed...
published on Monday, the 31. December 2008, macosxhints
Permanently delete files via AppleScript
Ever since switching to OS X from Windows, I've missed the convenience of being able to permanently delete files using Shift-Delete. In order to duplicate that functionality, I've written a short AppleScript that will delete the files selected in Finder instead of placing them in the trash. set frontAppPath to (path to frontmost application) as string if the frontAppPath ends with ":Finder.app:" then tell application "Finder" set selectionList to get selection as list set selectedCount to count items in selectionList if selectedCount > 0 then repeat with i from 1 to number of items in the selectionList set selectedItem to item i of the selectionList set selectedName to the name of sele...
published on Thursday, the 29. November 2007, macosxhints
Large Files Search 1.0
The problem: The disk on my computer was getting quite full, so I wanted to see what the largest files on the disk were. (This really helped--the first time I ran it, I found a runaway log file that was over 10GB.) The solution: An AppleScript script that's a much more user-friendly wrapper for the Mac OS X UNIX 'find' command. When you run this script, you will be prompted for a folder to put aliases of the large files into as well as the minimum size of the files to search for. The script will then use 'find' to create a list of the large files and alias them into that folder.
published on Sunday, the 11. November 2007, scriptbuilders
Clear out missing files in iTunes
I've moved my iTunes library around from machine to machine for about four machines now, and in the process, many files get lost or missing. But iTunes keeps the references to those files around, resulting in the (to me) dreaded circle-exclamation-point icon, and the task of either finding the file or deleting the reference. So I sat down and worked out this AppleScript... tell application "iTunes" set thePlaylist to library playlist 1 set musicFiles to the file tracks of thePlaylist repeat with mf in musicFiles --the name of mf as string set hasLoc to "" if (the location of mf as string ¬ is equal to "missing value") then try set comment of mf to the comment of mf & "" on error number errNum delete mf end try end if end repeat end tell The script goes through the entire library looking for file tracks (stream tracks, for example) and first checks to see if t...
published on Thursday, the 15. March 2007, macosxhints
Add To Dos to iCal from a text file using AppleScript
I sometimes keep a list of To Dos in text files or Stickies, since I'm not a big user of calendar apps. However, I'm leaving on a trip and needed to sync my To Dos with my cell phone, so I decided to create an AppleScript that reads a text file and converts each line into an iCal To Do item. When running it you just need to specify the text file to read. It will add ToDos to the Home calendar, but that's easy to change. Here's the code: tell application "iCal" set myFile to (choose file with prompt ¬ "Select a text file to read for To Dos:" of type {"TEXT"}) open for access myFile set myFileContents to read myFile close access myFile set the paragraph_list to every paragraph of myFileContents repeat with i from 1 to the count of paragraphs of myFileContents set thisTodo to paragraph i of the myFileContents if (thisTodo is not "") then set newtodo to (make new todo at end of ¬ todos of calendar "Home") tell newtodo set p...
published on Tuesday, the 20. February 2007, macosxhints
Create Windows-safe filenames via AppleScript
If you have a file server that you are connecting to using SMB, and that also shares files with Windows users, then there are some naming rules that you should follow to make sure your files are readable by Windows users. (This also applies when copying files to FAT32 formatted disks for Windows users to access). So I wrote an AppleScript to do just that.It will accept any combination of files or folders using drag and drop, run through the entire list of files and folders, and rename them according to two lists you can edit. The first list is characters that can cause problems in filenames, and the second list is characters that can cause problems if they are the first or last character in a file or folder name. You can change the substitute character, and the two lists, in the script properties.It will preserve extensions and handle duplicate name conflicts. It also presents...
published on Wednesday, the 31. January 2007, macosxhints