I am trying to use imagecatalog.jsx script built into indesign to make contact sheet. for some reason, any image where the suffix is in uppercase, it will not work.?
I found a script here to change lower to upper case and I am trying to get it work for my purposes by switching the information so that it finds all the uppercase letters and makes them lowercase.
I was not able to get it to run so that it would either ask me for files to to change or allow me to drag a folder on top of it?
Any help would be greatly appreciated.
tell application "Finder"
activate
on makeCaseLower(theString)
set lowercase to "abcdefghijklmnopqrstuvwxyz"
set UPERCASE to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set AppleScript's text item delimiters to " "
set theWords to text items of theString as list
set AppleScript's text item delimiters to ""
set newList to {}
repeat with theWord in theWords
set chrs to characters of theWord
set Nchrs to count chrs -- get the number of characters
repeat with K from 1 to Nchrs
if (item K of chrs) is in lowercase then
set olc to offset of (item K of chrs) in UPPERCASE
set item K of chrs to character olc of lowercase
end if
end repeat
set end of newList to chrs as string
end repeat
set AppleScript's text item delimiters to " "
set theString to newList as string
set AppleScript's text item delimiters to ""
return theString
end makeCaseLower
end tell
To change a string from uppercase to lowercase there are two smarter / shorter options.
Either you download and install SatImage osax then you can simply write
set lowerCasedString to lowercase "HELLO" --> "hello"
or with help from AppleScriptObjC you can use this handler
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
on toLowerCase(theString)
return (current application's NSString's stringWithString:theString)'s lowercaseString() as text
end toLowerCase
As you want to change only the file extension this code asks for a folder and changes all āJPGā extensions to ājpgā leaving the base names unchanged. It uses the AppleScriptObjC handler above
set baseFolder to choose folder
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is "JPG"
repeat with anImage in jpgImages
tell contents of anImage
set name extension to (my toLowerCase(get name extension))
end tell
end repeat
end tell
Just in case someone has a use for the handler āmakeCaseLowerā from the original post I noticed that the first use of UPERCASE in the script was āUPERCASEā (with one P), the the next reference was to āUPPERCASEā (with two Pās). When I corrected the mismatched UPPERCASE reference and removed the handler from the Finder tell block the handler appeared to work correctly.
makeCaseLower("JPG")
on makeCaseLower(theString)
set lowercase to "abcdefghijklmnopqrstuvwxyz"
set UPPERCASE to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set AppleScript's text item delimiters to " "
set theWords to text items of theString as list
set AppleScript's text item delimiters to ""
set newList to {}
repeat with theWord in theWords
set chrs to characters of theWord
set Nchrs to count chrs -- get the number of characters
repeat with K from 1 to Nchrs
if (item K of chrs) is in lowercase then
set olc to offset of (item K of chrs) in UPPERCASE
set item K of chrs to character olc of lowercase
end if
end repeat
set end of newList to chrs as string
end repeat
set AppleScript's text item delimiters to " "
set theString to newList as string
set AppleScript's text item delimiters to ""
return theString
end makeCaseLower
I am not able to download any software to the work computes, nadaā¦
So I tried this one first:
set baseFolder to choose folder
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is "JPG"
repeat with anImage in jpgImages
tell contents of anImage
set name extension to (my toLowerCase(get name extension))
end tell
end repeat
end tell
But got this error.
error āĀ«scriptĀ» doesnāt understand the ātoLowerCaseā message.ā number -1708 from Ā«scriptĀ»
I then tried my original one with the typo but still no go.
set baseFolder to choose folder
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is "JPG"
repeat with anImage in jpgImages
tell contents of anImage
makeCaseLower("JPG")
set lowercase to "abcdefghijklmnopqrstuvwxyz"
set UPPERCASE to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set AppleScript's text item delimiters to " "
set theWords to text items of theString as list
set AppleScript's text item delimiters to ""
set newList to {}
repeat with theWord in theWords
set chrs to characters of theWord
set Nchrs to count chrs -- get the number of characters
repeat with K from 1 to Nchrs
if (item K of chrs) is in lowercase then
set olc to offset of (item K of chrs) in UPPERCASE
set item K of chrs to character olc of lowercase
end if
end repeat
set end of newList to chrs as string
end repeat
set AppleScript's text item delimiters to " "
set theString to newList as string
set AppleScript's text item delimiters to ""
return theString
end tell
set name extension to (my toLowerCase(get name extension))
end makeCaseLower
end repeat
end tell
I get this error:
error āFinder got an error: document file "OBIT_RANDALL.JPG" of folder "test_JPG" of folder "Desktop" of folder "barbarapress" of folder "Users" of startup disk doesnāt understand the āmakeCaseLowerā message.ā number -1708 from document file āOBIT_RANDALL.JPGā of folder ātest_JPGā of folder āDesktopā of folder ābarbarapressā of folder āUsersā of startup disk
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
on toLowerCase(theString)
return (current application's NSString's stringWithString:theString)'s lowercaseString() as text
end toLowerCase
set baseFolder to choose folder
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is "JPG"
repeat with anImage in jpgImages
tell contents of anImage
set name extension to (my toLowerCase(get name extension))
end tell
end repeat
end tell
OK, I have been using the script and it has been great.
I tried to take it a step further and make every suffix, that I could think of, and have it make it lowercase. This is what I came up with and it seems like it worked, once, maybe twiceā¦but not since.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
on toLowerCase(theString)
return (current application's NSString's stringWithString:theString)'s lowercaseString() as text
end toLowerCase
set baseFolder to choose folder
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is "JPG"
set tifImages2 to files of baseFolder whose name extension is "TIF"
set psdImages3 to files of baseFolder whose name extension is "PSD"
set pngImages4 to files of baseFolder whose name extension is "PNG"
repeat with anImage in jpgImages
repeat with anImage2 in tifImages2
repeat with anImage3 in psdImages3
repeat with anImage4 in pngImages4
tell contents of anImage
set name extension to (my toLowerCase(get name extension))
end tell
tell contents of anImage2
set name extension to (my toLowerCase(get name extension))
end tell
tell contents of anImage3
set name extension to (my toLowerCase(get name extension))
end tell
tell contents of anImage4
set name extension to (my toLowerCase(get name extension))
end tell
end repeat
end repeat
end repeat
end repeat
end tell
If anyone could take a look and tell me what I am doing wrong that would be great.
Thanks!!!
Babs
For more than one extension create a list and check if the list contains the extension.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
on toLowerCase(theString)
return (current application's NSString's stringWithString:theString)'s lowercaseString() as text
end toLowerCase
set baseFolder to choose folder
set imageExtensions to {"JPG", "TIF", "PSD", "PNG"}
tell application "Finder"
set jpgImages to files of baseFolder whose name extension is in imageExtensions
repeat with anImage in jpgImages
tell contents of anImage
set name extension to (my toLowerCase(get name extension))
end tell
end repeat
end tell