Help with setting variable

This is probably very easy :rolleyes: , but I am unsure of how to do this and still have a lot to learn. I have a variable(fileVar) with a path to the original location of a file. I am moving that file to a new location. I need to get the path of the new file in a variable(dupefilevar). So that I can run a shell script on the new file and compare the results to the original file. When I display the path of dupefilevar after the move, it still retains the original path. Any suggestions would be great.
Paul

try
			move fileVar to folder dateFolder in folder ArtName in folder mastersPath in theFolder -->moves file into dated subfolder
set dupefilevar to filevar
					end try

here is the whole script that is almost done.

on write_to_file(this_data, target_file, append_data) -->SubRoutine for Log File
	try
		set the target_file to the target_file as text
		set the open_target_file to ¬
			open for access file target_file with write permission
		if append_data is false then ¬
			set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end write_to_file



set this_folder to choose folder

set mycountcopied to 0

tell application "Finder"
	set fileList to every file of this_folder
	set mycount to the number of items in fileList as Unicode text
end tell


set theFolder to alias "Masters_6TB:test:"
set matchedCodes to {}
repeat with thisFile in fileList
	set thisFilename to name of thisFile
	set filecode to text 1 thru 4 of thisFilename
	set filedate to text 6 thru 11 of thisFilename
	
	if (filecode is in matchedCodes) then
		-- If this file code has appeared earlier in the run, search the odd-numbered items of matchedCodes for it.
		set i to 1
		repeat until (item i of matchedCodes is filecode)
			set i to i + 2
		end repeat
		-- Read the artist name from the following, even-numbered item.
		set ArtName to item (i + 1) of matchedCodes
	else
		-- Otherwise, get the artist name from FMP.
		
		tell application "FileMaker Pro"
			open alias "Macintosh HD:Users:jayb:Documents:Filemaker Documents:artist_codes.fp7"
			try
				delete every request
			end try
			create request
			set cell "Code Number" of request 1 to filecode
			
			find
			
			set ArtName to field "Artist Name" of current record
			set mastersPath to field "File Location" of current record
		end tell
		
		-- Update the list of matched codes and artist names.
		set end of matchedCodes to filecode
		set end of matchedCodes to ArtName
		
		-- Try making a folder for this new artist.
		
		tell application "Finder"
			try
				make new folder in folder mastersPath in theFolder with properties {name:ArtName}
				
			end try
		end tell
	end if
	set dateFolder to filedate as string
	tell application "Finder"
		try
			make new folder in folder ArtName in folder mastersPath in theFolder with properties {name:filedate} -->creates dated subfolder
			
		end try
		
		set fileVar to thisFile as string
		
		try
			move fileVar to folder dateFolder in folder ArtName in folder mastersPath in theFolder -->moves file into dated subfolder
			set mycountcopied to (mycountcopied + 1) --->file counter
		end try
		
		
		set this_data to fileVar as text
		set this_file to (((path to desktop folder) as text) & "MastersLog")
		my write_to_file(this_data, this_file, true) --->Call to Log File SubRoutine
		
	end tell
	
end repeat
if mycountcopied < mycount then display dialog "Some Items Were Not Copied"
display dialog "Copied " & mycountcopied & " Files out of " & mycount

Model: Intel MacPro
AppleScript: 1.10.7
Browser: Firefox 2.0.0.1
Operating System: Mac OS X (10.4)

Hi Paul,

You can save the reference to a file as string. Then compare the strings. Here’s an example:


set test_file to choose file
set original_location to test_file as string
tell application "Finder"
	try
		set new_reference to (move test_file to desktop) as alias
		set new_location to new_reference as string
	on error -- file wasn't moved. It was on desktop
		set new_location to original_location
	end try
end tell
return new_location = original_location -- true or false

When you choose a file, the script moves it to the desktop. When you choose a file on the desktop, the file isn’t moved, so no reference is returned by the ‘move’ command. The error handler handles that.

BTW, copy (‘duplicate’) is not the same as move.

gl,

Thanks Kel,

That is pretty much what I needed. I didn’t know the correct way of doing it. Here is the code so far, still need to do something with the md5 info. Most of which is from is from Eelco Houwink( many thanks to him)

Paul

set original_location to thisFile as string
		set b to (POSIX path of original_location) as string
		
		
		try
			set new_location to (duplicate thisFile to folder dateFolder in folder ArtName in folder mastersPath in theFolder) as alias -->moves file into dated subfolder
			set mycountcopied to (mycountcopied + 1) --->file counter
		end try
		set c to (POSIX path of new_location) as string
		set md51 to last word of (do shell script "md5 '" & b & "'")
		set md52 to last word of (do shell script "md5 '" & c & "'") --same for duplicate
		display dialog md51 & "  " & md52