AppleScript Error -1700 - what does this mean?

hi,
i’ve been working on this script for a time now. it has to compare text files in one folder, with text files in another folder.
before this, i was trying to compare just 2 text files, but the size of the files was of 30mb each, and the system returned “out of memory”.
so i now i have 30 files for each larga file. and i want to compare them.
each file has the same structure:

file:

MD5 (/Volumes/folder/subfolder/file1.jpg) = 194577a7e20bdcc7afbb718f502c134c
MD5 (/Volumes/folder/subfolder/file2.jpg) = 8df4d01824e6538c2bd06bc252180522
MD5 (/Volumes/folder/subfolder/file3.jpg) = cfa5eaff431641a376de8d7d7191a803
MD5 (/Volumes/folder/subfolder/file4.jpg) = a1b586895c87bf91bc463a73a0f6c575
MD5 (/Volumes/folder/subfolder/file5.jpg) = 81a9792bc22ae12cf00451e6f7b65fab

and this is my script (with the Bruce’s ProgressBar added)


set folder1 to (choose folder with prompt "Select folder of source databases") as string
set folder2 to (choose folder with prompt "Select folder of target databases") as string

tell application "System Events"
	set files1 to every file of folder folder1
	set files2 to every file of folder folder2
end tell

set Progress to load script (path to resource "Progress.scpt")

tell Progress
	initialize()
	setTitle to "Compare Parsed Databases"
	changeIcon to POSIX path of (path to resource "m.jpg")
	barberPole(false)
	setMax to number of items in files1
end tell

set c to 1

try
	repeat with i from 1 to (count items of files1)
		
		set log1 to (item i of files1 as alias)
		set log1info to info for log1
		
		set log2 to (item i of files2 as alias)
		set log2info to info for log2
		
		if (visible of log1info is true and alias of log1info is false) and (visible of log2info is true and alias of log2info is false) then
			set log_1 to read file (log1 as string) as Unicode text
			set log_2 to read file (log2 as string) as Unicode text
			
			set log_1_items to paragraphs of log_1
			set AppleScript's text item delimiters to {" = "}
			
			tell Progress
				setStatusTop to ("Comparing " & (name of log1info) & " with " & (name of log2info))
				setStatusBottom to ("Files left: " & ((number of items in files1) - c))
			end tell
			
			repeat with j from 1 to ((count of log_1_items) - 1) by 1
				if log_2 does not contain item 2 of (text items of (item j of log_1_items)) then
					do shell script "echo " & (quoted form of (item j of log_1_items)) & " >> ~/Desktop/NoMatch.txt"
				end if
			end repeat
		end if
		
		tell Progress to increase by 1
		set c to (c + 1)
		
	end repeat
	tell Progress to quit
on error err
	display dialog err
	tell Progress to quit
end try

this should compare the first item of one folder, with the first of the second; then the second from one to the second of the other, and so on. and when it finds that a file from one IS NOT in the other, it should print it in a .txt file.
but i get this error:

Could not run this script because of an Apple Event error.
-1700

it happens in the middle of the script, so i assume that something with the shell script is messing things up…
i can’t find what does -1700 mean, and i don’t see anything wrong ( at least with my newbie eyes :smiley: )

if anyone could give me a hint, i would much appreciate it.

thanks guys!!!

Marto.

Hi Marto,

error -1700 is Can’t make some data into the expected type., an coercing error

You can find all AppleScript errors here

:o
uh… ok. but i still can’t figure out whats wrong… i mean…

this is a script that James Nierodzik handed to me:


set log_1 to read file ((choose file) as Unicode text)
set log_2 to read file ((choose file) as Unicode text)
set log_1_items to paragraphs of log_1
set AppleScript's text item delimiters to {" = "}
repeat with i from 1 to ((count of log_1_items) - 1) by 1
   if log_2 does not contain item 2 of (text items of (item i of log_1_items)) then
       do shell script "echo " & (quoted form of (item i of log_1_items)) & " >> ~/Desktop/NoMatch.txt"
   end if
end repeat


and it works perfectly.
so i see no difference between them and i’m stucked here…
any ideas?

May be it’s the text encoding. Are you sure, the text files are UTF 16 encoded?

the files were created with this:


do shell script "find " & quoted form of POSIX path of aFolder & " -name pwg_high -type d -exec find {} -name " & quoted form of fileName & " \\; | xargs md5 >> " & quoted form of POSIX path of sigFilePath

but since i really don’t know what’s the text encoding of this, i re-saved them all with the UTF 16.

it still returns the -1700 error…

Try changing your two read statements to this…


set log_1 to read file (log1 as Unicode text)
set log_2 to read file (log2 as Unicode text)

the difference between the two read statements are:

set log_1 to read file ((choose file) as Unicode text)

coerces the chosen file (an alias) to an Unicode text path and reads the text with MacRoman encoding

set log_1 to read file (log1 as string) as Unicode text

reads the file with UTF16 encoding

well.
so, StefanK, i was using the UTF16 after all, but the original script wasn’t.
either way, the script doesn’t run.

with your modification, James, it returns:

Can’t make item 2 of every text item of item 18 of {"MD5…

the error message is too long, asi if it tryed to return the whole file, and i can’t see how it finishes… :stuck_out_tongue:

I guess the problem is the run /load script lines.
path to resource doesn’t work, when you run a script in Script Editor.

yes. i know that resource doesn’t work, but thats because i’m writing a bundle app, so it can run the Progress bar on its own…

run/load?

you that i should add a


on run
--script
end run

?

no, I meant just the load script / run script lines.
Can you disable this progress bar stuff, run the script in Script Editor and look, where the error occurs

i commented every reference to the Progress Bar.
it still returns the same error, at the same repeat.
the one with this lines


try
					repeat with j from 1 to ((count of log_1_items) - 1) by 1
						if log_2 does not contain item 2 of (text items of (item j of log_1_items)) then
							do shell script "echo " & (quoted form of (item j of log_1_items)) & " >> ~/Desktop/NoMatch.txt"
						end if
					end repeat
				on error err2
					display dialog ("SECOND: " & err2)
				end try

Error:

SECOND: Can’t make item 2 of every text item of item 19 of {"MD5 (/Volumes/…
and writes the whole file so i can’t see the end.

ideas?

is there a “missprint” in item 19 of the file?

crank up the detail of your error report. what value does i and j have when the script dies, then look at the files n question and figure out where in there its dying and why.