i got to the part where i can read contents of a folder and put this into a file, but only with bash
and i cant seem to include a repeat loop into the middle of a bash syntax
set theFile to "/Users/xax/Desktop/snf/lol.txt"
set line1 to "<a href=\""
set line2 to "\" target=_blank>"
set line3 to "<img src=\""
set line4 to "\" border=0></a>"
do shell script "echo " & quoted form of line1 & "blah" & quoted form of line2 & quoted form of line3 & "blobb" & quoted form of line4 & " > " & theFile
i only got that far. i would need every file in a folder instead of “blah”, so it results in a file which shows:
i hope i could make myself more or less understandable…
every help is welcome, thanks upfront already, i already learned a lot from this board
ps: my real name is XiaoSu Han, since i got deleted once already i think
choose folder with prompt "Create links for files in this folder:"
set nameList to list folder result without invisibles
set newFileContent to {}
repeat with thisName in nameList
set newFileContent's end to "<a href\"" & thisName & "\" target=\"_blank\"><img src=\"tn_" & thisName & "\" border=\"0\"></a>"
end repeat
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10}
set newFileContent to newFileContent as Unicode text
set AppleScript's text item delimiters to ASTID
choose file name
try
set fileRef to open for access (result) with write permission
write newFileContent to fileRef starting at 0
close access fileRef
on error errMsg number errNum
try
close access fileRef
end try
display dialog "Error " & errNum & ":" & return & return & errMsg buttons "Cancel" default button 1 with icon caution
end try
Maybe assemble your string outside of the shell script?
You can hardcode the folder path and use “ls”, add a check to make sure they’re all jpg’s etc., but here it is using the finder:
set theFile to "/Users/xax/Desktop/snf/lol.txt"
set line1 to "<a href=\""
set line2 to "\" target=_blank>"
set line3 to "<img src=\""
set line4 to "\" border=0></a> "
tell application "Finder"
set theFolderList to list folder (choose folder) without invisibles
end tell
set bigString to ""
repeat with aFileName in theFolderList
set theText to line1 & aFileName & line2 & line3 & "tn_" & aFileName & line4
set bigString to bigString & theText
end repeat
do shell script "echo " & quoted form of bigString & " > " & theFile
Is it not possible to use Image Events or something? That’s the route I was going to try to take. It sure would be cool to not require 3rd party app. But if I must, I must.
BIg fan of ImageMagick, but I havent been thrilled with the quality of the output in certain situations. Then again, I haven’t fully explored all of the format options.
I use a AS to call Photoshop Actions. I find it easy to set up an action where I’m able to tweak quality (dimensions, post resize sharpening, jpeg quality, etc) on a batch by batch basis if necessary.
It’s not nearly as fast as ImageMagick, but I’m only doing a few hundred images at a time, not thousands.
As a side note, I’ve never gotten consistent results from Image Events. I dunno why, but something always seems to go wrong when I try to incorporate it into a workflow.