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)