| Running Windows (or anything else) on your Mac Discussion of Classic or running Windows, Linux and other OSes on the Mac. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Aug 25, 2006
Posts: 82
![]() Mac Specs: MacBook
|
Hi, I am trying to use Applescript to run something so that in a folder, all the files with the extension ".xyz" would be changed to ".abc"
Can someone give me a hand? I searched online for something and I found a file called "extensionchange.action" but I don't know what application is needed to open that file. Thanks. |
| QUOTE Thanks | |
![]() Member Since: Mar 30, 2004
Location: USA
Posts: 4,744
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 12" Apple PowerBook G4 (1.5GHz)
|
What you have is an Automator action, for OS X 10.4.
This thing sounds like what you were looking for. Past it into the Applescript editor and give it a trial run. |
| QUOTE Thanks | |
![]() Member Since: Aug 25, 2006
Posts: 82
![]() Mac Specs: MacBook
|
tell current application choose folder with prompt "Select folder to rename files in:" alias "Hard Drive::new:" display dialog "Extension to Replace:" default answer "" {text returned:"abc", button returned:"OK"} display dialog "Replace With:" default answer "" {text returned:"xyz", button returned:"OK"} end tell tell application "Finder" get every file of alias "Hard Drive:new:" whose name ends with "abc" {alias "Hard Drive:new: ssscon08.abc"} select file (alias "Hard Drive:new: ssscon08.abc") document file " ssscon08.abc" of folder "new" of startup disk get name of alias "Hard Drive:new: ssscon08.abc” " ssscon08.abc” offset of "abc" in " ssscon08.abc" 15 set name of selection to "ssscon08.xyz" "Finder got an error: Can't set name of selection to \" ssscon08.xyz\"." |
||||
| QUOTE Thanks | |||||
![]() Member Since: Mar 11, 2004
Location: Winnipeg
Posts: 1,964
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: G4 — Tiger and OS 9
|
I found a script here that I changed to this:
tell application "Finder" activate set the chosen_folder to (choose folder with prompt "Pick the folder containing the files :") repeat with i from 1 to count of file in chosen_folder set this_text to name of file i of chosen_folder set AppleScript's text item delimiters to ".xyz" set AppleScript's text item delimiters to "/" set this_text to every text item of this_text if (count of characters of this_text) > 27 then set this_text to (characters 1 thru 27 of this_text) end if set AppleScript's text item delimiters to "" set name of file i of chosen_folder to this_text & ".abc" as string end repeat end tell After booting into System 9, I created four SimpleText documents, each with the suffix .xyz, and dropped them into a folder. Then I pasted the above script into a blank Script Editor document and clicked on "Run." A dialog popped up asking me to click on the folder with the documents, and lo and behold, the script changed each one. Colour me astonished. Before running it on your important files, you should try it first with dummy documents, just to be sure it will work properly with your version of AppleScript. You'd likely have to change the number 27 to whatever number of documents are in the folder. Edit: I spoke too soon. I tried it a second time, and it's adding the second suffix to the first. I'll keep working on it. Last edited by Brown Study; 03-16-2007 at 04:34 PM. |
| QUOTE Thanks | |
![]() Member Since: Oct 27, 2005
Posts: 4,714
![]() |
Quote:
Your Mac comes with a script already written to do this very job. First you need to enable it by following the info in this link: http://www.apple.com/ca/pro/tips/applescript.html Firstly find and highlight all the items you need to effect a change to and then click on the AppleScript icon in the menubar to the right of the DeskTop and navigate to: Finder Scripts>Replace Text in Item names. Then follow the prompts and the task is done. I tested this out on a folder of .mid files and successfully altered the extension from .mid to .mad ... completely unreadable by any app but at least it worked. I then used the script to change them back again. |
|
| QUOTE Thanks | ||
![]() Member Since: Mar 11, 2004
Location: Winnipeg
Posts: 1,964
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: G4 — Tiger and OS 9
|
|
| QUOTE Thanks | |
![]() Member Since: Mar 11, 2004
Location: Winnipeg
Posts: 1,964
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: G4 — Tiger and OS 9
|
|
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| List view vs. Icon view - can't see all files | =^o.o^= | Switcher Hangout | 8 | 01-20-2007 06:39 PM |
| Changing the location where files are downloaded to: | essie | OS X - Operating System | 6 | 12-04-2006 06:31 PM |
| Files Lost during Profile Move | SITF | OS X - Operating System | 0 | 10-17-2006 03:54 PM |
| Changing the file extensions on a number of files | meatychi | Running Windows (or anything else) on your Mac | 8 | 01-19-2006 07:30 AM |
| repair permissions a waste of time? | Macman | Schweb's Lounge | 5 | 05-31-2005 06:26 PM |
All times are GMT -4. The time now is 08:38 PM.
Powered by vBulletin