Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
Running Windows on your Mac
Applescript - changing the extension of files
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Brown Study" data-source="post: 350013" data-attributes="member: 3889"><p>I found a script <a href="http://bbs.applescript.net/viewtopic.php?id=9760" target="_blank"><strong>here</strong></a> that I changed to this:</p><p></p><p>tell application "Finder"</p><p> activate</p><p> set the chosen_folder to (choose folder with prompt "Pick the folder containing the files :")</p><p> repeat with i from 1 to count of file in chosen_folder</p><p> set this_text to name of file i of chosen_folder</p><p> set AppleScript's text item delimiters to ".xyz"</p><p> set AppleScript's text item delimiters to "/"</p><p> set this_text to every text item of this_text</p><p> if (count of characters of this_text) > 27 then</p><p> set this_text to (characters 1 thru 27 of this_text)</p><p> end if</p><p> set AppleScript's text item delimiters to ""</p><p> set name of file i of chosen_folder to this_text & ".abc" as string</p><p> end repeat</p><p> end tell</p><p></p><p>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.</p><p></p><p>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.</p><p></p><p>You'd likely have to change the number 27 to whatever number of documents are in the folder.</p><p></p><p><strong>Edit:</strong> 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.</p></blockquote><p></p>
[QUOTE="Brown Study, post: 350013, member: 3889"] I found a script [URL="http://bbs.applescript.net/viewtopic.php?id=9760"][B]here[/B][/URL] 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. [b]Edit:[/b] 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. [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
Apple Computing Products:
Running Windows on your Mac
Applescript - changing the extension of files
Top