|
|
#1 |
|
AppleScript help
Just want to make a very basic AppleScript that, once pointed at a folder will rename them all to: "8993-myname-1", the '1' would be incremented for each picture. I have Visual Basic.NET programming experience, as well as some C++, but AppleScript always seems to elude me...
Thanks!
__________________
This is not the signature you're looking for. This is not the signature we're looking for. You can scroll down now. You can scroll down now. Last edited by Mechcozmo; Sep 26, 2004 at 05:27 PM. |
|
|
|
0
|
|
|
#2 |
|
I got this from another site. Perhaps it will do what you want.
Code:
property nameString : ""
property extension : ""
tell application "Finder" to set theFiles to selection
if number of items in theFiles is greater than 0 then
display dialog "Please enter the new name for the files:" default answer nameString
set nameString to text returned of the result
display dialog "Enter a file extension, or leave blank for none:" default answer extension
set extension to text returned of the result
if the nameString is not "" then
repeat with i from 1 to number of items in theFiles
set thisItem to item i of theFiles as alias
set thisInfo to info for thisItem
set currentName to name of thisInfo
if extension is "" then
set extensionString to ""
else
set extensionString to "." & extension
end if
if i is 1 then
set newName to nameString & extensionString
else
set newName to nameString & " " & (i as string) & extensionString
end if
my setItemName(thisItem, newName)
end repeat
end if
else
display dialog "No items are selected" buttons "OK" default button 1
end if
on setItemName(thisItem, newName)
tell application "Finder"
set parentFolder to (container of thisItem) as text
if not (exists item (parentFolder & newName)) then
try
set name of thisItem to newName
on error errorMessage number errorNumber
tell me to display dialog ("An error occured when renaming to" & newName & ". The file will not be renamed.") buttons "OK" default button 1
return 0
end try
else --the name already exists
tell me to display dialog ("A file named" & newName & " already exists. The file will not be renamed.") buttons "OK" default button 1
return 0
end if
end tell
end setItemName
__________________
Oh do pay attention 007. In the wrong hands, this cylindrical 12-core Mac Pro with three 4K displays, FirePro graphics, and Thunderbolt 2 could be very dangerous. |
|
|
|
0
|
|
|
#4 |
|
Very neat. The program, BTW, is for Yearbook. The two photographers (me and someone else) need to rename the pictures according to some style that the printer needs.
The other photographer has a 15" PowerBook (Rev. B or C, dunno) The only thing that I wonder about, is that whole order thing that is mentioned in the other post. But, I guess if I were to tell that window to be displayed acording to Date Created, everything would be fine and dandy? Thank you so much, in any case. EDIT: Tested it out, the only problem I forsee is with the name extensions, but if I tell it .jpg it should work...I still like the OS 9 way of doing things, with the Creator codes. But it does work, and work well. Now I don't have to rename 100 pictures a week by hand!
__________________
This is not the signature you're looking for. This is not the signature we're looking for. You can scroll down now. You can scroll down now. Last edited by Mechcozmo; Sep 26, 2004 at 06:34 PM. |
|
|
|
0
|
|
|
#5 | |
|
Quote:
__________________
Oh do pay attention 007. In the wrong hands, this cylindrical 12-core Mac Pro with three 4K displays, FirePro graphics, and Thunderbolt 2 could be very dangerous. |
||
|
|
0
|
|
|
#6 | ||
|
Quote:
Quote:
|
|||
|
|
0
|
|
|
#7 |
|
possible simple solution
If I understand your problem, then the script I have just written ought to work for you. Here it is:
set folderpath to (choose folder with prompt "Which folder would you like to rename the contents of?") tell application "Finder" set filelist to files in folderpath set n to 0 repeat with afile in filelist set newfilename to "8993-myname-" & n + 1 set name of afile to newfilename set n to n + 1 end repeat end tell If this script is not quite what you want, please contact me either via the forum or email at cj.lusty@ukf.net. Good luck! p.s. this script is based on, but not copied from, a script in the book "Beginning mac os x programming" by Stephen Kochan. I highly recomend it to anyone wanting to gain a thorough grounding in the basics of applescript |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Handling Duplicate AppleScripts | the Otter | Mac Programming | 1 | Dec 22, 2010 05:53 AM |
| Applescript NOOB | Revolume | Mac Programming | 2 | Dec 1, 2010 08:06 AM |
| help with excel for mac 2008 | damiang72 | Mac Applications and Mac App Store | 0 | Nov 14, 2010 06:19 AM |
| AppleScript Help | krohde | Mac Help/Tips | 2 | Mar 20, 2003 05:06 PM |
| AppleScript help | cleo | General Mac Discussion | 0 | Apr 10, 2002 08:21 PM |
All times are GMT -5. The time now is 01:05 PM.







Linear Mode

