We've finished our move from .Mac to our very own domain
name: http://www.brettgrossphotography.com/ .
Woo hoo!
Find-Replace in Name
Current
version: 02
Built on: Aperture 1.5.4
This AppleScript operates on the selection.
This script will replace a specific string in the names of
selected images with something else. It does exactly what
it sounds like it should.
Download
--
-----------------------------------------------------------------------------------------------------------------------
on
run
tell
application
"Aperture"
activate
copy
selection
to
theSel
set
name1
to
name
of
(item
1
of
theSel)
log
name1
--
tell application "System Events"
set
theOut
to
display dialog
"Enter the text to search for:"
default answer
name1
buttons
{"OK", "Cancel"}
default button
1
set
findStr
to
text returned
of
theOut
set
theOut
to
display dialog
"Enter the replacement text:"
default answer
name1
buttons
{"OK", "Cancel"}
default button
1
set
repStr
to
text returned
of
theOut
--
end tell
set
showList
to
{}
repeat
with
curImg
in
theSel
set
oldName
to
name
of
curImg
set
newName
to
my
findRep(oldName, findStr, repStr)
set
addline
to
(oldName & " -- " & newName)
set
end
of
showList
to
addline
end
repeat
choose
from list
showList
with prompt
"Here is what the new names will look like:"
with
empty selection allowed
repeat
with
curImg
in
theSel
set
oldName
to
name
of
curImg
set
newName
to
my
findRep(oldName, findStr, repStr)
set
name
of
curImg
to
newName
log
newName
end
repeat
end
tell
end
run
--
---------------------------------------------------------------------------------------------------------------------
on
findRep(srcText, findStr, repStr)
set
findLoc
to
offset
of
findStr
in
srcText
log
findLoc
if
findLoc
is
0
then
--
------------------------------------------ string isn't in
source string
return
srcText
else
set
findLen
to
(length
of
findStr)
try
set
str1
to
(text
1
thru
(findLoc - 1)
of
srcText)
as
string
on
error
set
str1
to
""
end
try
log
str1
try
set
str2
to
(text
(findLoc + findLen)
thru
-1
of
srcText)
as
string
on
error
set
str2
to
""
end
try
log
str2
set
outStr
to
(str1 & repStr & str2)
as
string
log
outStr
return
outStr
end
if
end
findRep