Let me disagree with your workaround.
Look at this example.
on removeExtension(thisName)
if thisName contains "." then
set thisName to (the reverse of every character of thisName) as string
set x to the offset of "." in thisName
set thisName to (text (x + 1) thru -1 of thisName)
set thisName to (the reverse of every character of thisName) as string
end if
return thisName
end removeExtension
set thisName to "Macintoh HD:Users:moi:Documents:31.12.43:myFile"
my removeExtension(thisName) --> "Macintoh HD:Users:moi:Documents:31.12"
No need to reinvent the wheel.
For years, stripping the extension is done with such kind of code.
property openTypes : {"PDF", "com.adobe.pdf", "BMP", "com.microsoft.bmp", "PICT", "com.apple.pict", "PNG", "public.png", "PSD", "com.adobe.photoshop-image", "TIFF", "public.tiff"}
--Get the artwork file
set theFiles to choose file with prompt "Choose art file(s)" of type openTypes without invisibles
set theType to "JPG"
runTest(theFiles, theType)
on runTest(theArt, theType)
display dialog "theArt is " & theArt
tell application "Finder"
set theExt to name extension of theArt
set theArt to theArt as string
if theExt is "" then
set noExtPath to theArt as string
else
set noExtPath to (text items 1 thru -(2 + (count theExt)) of theArt) as string
end if
set theNewArt to noExtPath & "." & theType
end tell
display dialog "theNewArt is " & theNewArt
end runTest
I know that some helpers dislike to use the Finder (I’m one of them but here, you already used it, with no real need) to drop the name extension.
But they take care to drop it from the file name, not from the file path as your code does.
It’s why I took care to use a varName matching what it’s supposed to contain.
I’m a bit puzzled by your first instruction.
As far as I know you would get the same behaviour with this shorter one:
property openTypes : {"com.adobe.pdf", "com.microsoft.bmp", "com.apple.pict", "public.png", "com.adobe.photoshop-image", "public.tiff"}
If you wish to experiment you may try to use this instruction:
set showExtensions to do shell script "defaults read com.apple.finder AppleShowAllExtensions"
If it returns 1, your paths are supposed to have an extension, if it returns 0 they are supposed to haven’t. I wrote ‘are supposed’ because my memory which may be facetious tell me that this feature doesn’t apply to path of applications.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) Wednesday 22 April 2020 18:25:45