JPG and JPEG problem

When you create a picture with a script, downloading a data from the URL, like “picture.jpg”, DT creates the record, where extention of the file is not jpg… It’s “picture.jpeg”, I mean with JPEG extention. So, if you will try to find a file by name from the URL, you will get error. Simply renaming a file - is a bad idea, and filename property is “get only”…

Is there an easy way to create record with the original extention?

Could you please post the script? An example of a picture URL would be useful too. Thanks.

No problem, take this one e.g.
You may take any other picture with “JPG” extention, script will turn it to “JPEG”

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set theURL to ""

tell application id "DNtp"
	set PictureData to download URL theURL
		set theResponse to last downloaded response
		set DownloadedURL to last downloaded URL
		set theStatus to |http-status| of theResponse
		if theStatus ≤ 0 or (theStatus ≥ 400 and theStatus is not 403 and theStatus is not 405 and (theStatus is not 404 or theURL does not contain "")) then error
		set thePicture to create record with {URL:theURL, type:picture} in incoming group of current database
		set data of thePicture to PictureData
		set theFilename to filename of thePicture
		display dialog theFilename buttons {"OK"} default button "OK"
	on error
		display dialog "invalid url response" buttons {"OK"} default button "OK"
	end try
end tell

The next release will fix this.

1 Like

Thank you!