G’day
I’ve got a bit of a dilemma.
I’ve written a batch file/folder renamer,
http://scriptbuilders.net/files/itemrenamer2.4.html
but one of the users reports that the number usuallly appended to the name before the extension is actually being placed after the extension on odd occasions.
I haven’t been able to duplicate the error.
Is it possible that something like a carriage return is located after the extension name, and the script calling the Finder can’t ‘see’ it?
Thanks,
Santa
The bit of script checking the extension is…
on GoAndRename(TheFolderItem)
try
tell application "Finder"
set temp3 to ""
set AddToName to 2 -- The 'add-on to name' item
set NameItem to TheFolderItem as alias
set TheName to (displayed name of (info for (NameItem)))
set NewName to TheName
if TheName is not in AllTheExistingNames then
set AllTheExistingNames to AllTheExistingNames & TheName
return TheName
else
if (extension hidden of (info for (NameItem))) = false then
set temp3 to "." & (name extension of (info for (NameItem)))
-- Now set main string for name, minus extension
if temp3 = ".missing value" then
set temp3 to ""
else
set TheName to my replace_chars(TheName, temp3, "")
end if
end if
repeat
set NewName to TheName & " " & (AddToName as string) & temp3
(* Now we have to check two states...
1. Does the re-named file exist in the destination folder,
2. is there a conflict in the present folder if we re-name.
*)
if NewName is not in AllTheExistingNames then
if my CheckAllTheNewItems(NewName) < 2 then
exit repeat
end if
else
set AddToName to AddToName + 1
end if
end repeat
end if
end tell
end try
set AllTheExistingNames to AllTheExistingNames & NewName
return NewName
end GoAndRename
Model: G5 1.8 GHz
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)