ok so i know that this is a long script but i only need help with a way to reset the execution point a certain line of the script. i have commented where i need to do this, about 3/4 of the way down the script. but, if anyone would like to give advice to streamline this or if i have some syntax wrong, i wont object to the help haha!
ok so here it is:
ok so here it is:
Code:
on write_extension_error(thatData, logLocation, append_data)
try
set the logLocation to the logLocation as text
set the openLog to ¬
open for access file logLocation with write permission
if append_data is false then ¬
set eof the openLog to 0
write thatData to the openLog starting at eof
close access the openLog
return true
on error
try
close access file logLocation
end try
return false
end try
end write_extension_error
on removeFilesh(rmLocation)
try
do shell script "rm '" & rmLocation & "'"
end try
end removeFilesh
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 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 with prompt "Choose Source Location"
set jpgToTifExten to 0
set problemFiles to {}
set filesWithExtenChng to {}
set mycountcopied to 0
set iteration to 1
tell application "Finder"
set filelist to every file of this_folder
set total_count to the number of items in filelist as Unicode text
end tell
set theFolder to alias "Masters_6TB:JPEG_masters:"
set matchedCodes to {}
repeat with thisFile in filelist
with timeout of 43000 seconds
set thisFilename to name of thisFile
set filecode to text 1 thru 4 of thisFilename
set filedate to text 6 thru 11 of thisFilename
set theName to text 1 thru 18 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 + 3
end repeat
-- Read the artist name from the following, even-numbered item.
set ArtName to item (i + 1) of matchedCodes
set mastersPath to item (i + 2) of matchedCodes
else
-- Otherwise, get the artist name from FMP.
tell application "FileMaker Pro Advanced"
activate
with timeout of 43000 seconds
open alias "Masters_6TB: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 timeout
end tell
tell application "Finder" to set visible of process "FileMaker Pro" to false
-- Update the list of matched codes and artist names.
set end of matchedCodes to filecode
set end of matchedCodes to ArtName
set end of matchedCodes to mastersPath
end if
-- Try making a folder for this new artist.
tell application "Finder"
set folderList to {}
if folder ArtName in mastersPath in theFolder exists then
set myFolder to folder ArtName in folder mastersPath in theFolder
set AppleScript's text item delimiters to ","
set folderContents to the name of every file of entire contents of myFolder
set matchedFolderList to every file of entire contents of myFolder
set u to 1
repeat with thatFile in matchedFileFolder
set itsName to ""
set itsName to the name of thatFile as text
set newName to text 1 thru 18 of itsName
set itemNumber to u as integer
if newName is theName then
if name extension of thatFile is "jpg" then
set thatFile's name extension to "tif"
set fileListUpdate to every file of entire contents of myFolder
set newFile to item itemNumber in fileListUpdate
if name extension of newFile is "tif" then
set jpgToTifExten to (jpgToTifExten + 1)
else
set pFiles to (pFiles & ("JPG EXTEN PROB: " & {newFile}))
end if
end if
set newMatchedFileFolder3 to every file of entire contents of myFolder
set fileToDelete to (item itemNumber of newMatchedFileFolder3)
set fCont to the name of the container of fileToDelete as Unicode text
if fCont is filedate then
set fileLoc to (container of fileToDelete) as string
set origLoc to thisFile as string
set newLoc to (duplicate thisFile to fileLoc with replacing) as alias
set d to (POSIX path of origLoc) as string
set e to (POSIX path of newLoc) as string
set md51 to last word of (do shell script "md5 '" & d & "'")
set md52 to last word of (do shell script "md5 '" & e & "'")
try
if md51 = md52 then
set mycoutncopied to (mycountcopied + 1)
set label index of thisFile to 7
else
set problemFiles to problemFiles & {thisFile}
set label index of thisFile to 2
set filesWithExtenChng to (filesWithExtenChng & {fileToDelete})
end if
on error
set problemFiles to problemFiles & {thisFile}
set this_data to problemFiles as text
set errorVar to (((path to desktop folder) as text) & "MastersLog")
my write_to_file(this_data, errorVar, true)
set thatData to filesWithExtenChng as text
set logLocation to (((path to desktop folder) as text) & "ExtenChngLog")
my write_extension_error(thatData, logLocation, true)
end try
else
set subFolderName to filedate as string
try
make new folder in folder ArtName in folder mastersPath in theFolder with properties {name:subFolderName}
end try
set newLoc to (duplicate thisFile to folder subFolderName in folder ArtName in folder mastersPath in theFolder) as alias
set origLoc to thisFile as string
set d to (POSIX path of origLoc) as string
set e to (POSIX path of newLoc) as string
set md51 to last word of (do shell script "md5 '" & d & "'")
set md52 to last word of (do shell script "md5 '" & e & "'")
set rmLocation to (POSIX path of fileToDelete) as string
try
if md51 = md52 then
set mycoutncopied to (mycountcopied + 1)
set label index of thisFile to 7
my removeFilesh(rmLocation)
else
set problemFiles to problemFiles & {thisFile}
set label index of thisFile to 2
set filesWithExtenChng to (filesWithExtenChng & {fileToDelete})
end if
on error
set problemFiles to problemFiles & {thisFile}
set this_data to problemFiles as text
set errorVar to (((path to desktop folder) as text) & "MastersLog")
my write_to_file(this_data, errorVar, true)
set thatData to filesWithExtenChng as text
set logLocation to (((path to desktop folder) as text) & "ExtenChngLog")
my write_extension_error(thatData, logLocation, true)
end try
end if
set u to (u + 1)
(*--------help needed here--------this is where i would like to skip to the end of the script, the "display dialog "All done"" part, since it has already matched the file name and replaced it. i have been looking around to find a command or a subroutine to help with this but have had no luck yet.*)
else
set u to (u + 1)
end if
end repeat
else
try
make new folder in folder mastersPath in theFolder with properties {name:ArtName}
end try
set dateFolder to filedate as string
try
make new folder in folder ArtName in folder mastersPath in theFolder with properties {name:filedate} -->creates dated subfolder
end try
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 c to (POSIX path of new_location) as string
end try
set md51 to last word of (do shell script "md5 '" & b & "'")
try
set md52 to last word of (do shell script "md5 '" & c & "'") --same for duplicate
end try
try
if md51 = md52 then
set mycountcopied to (mycountcopied + 1) --->file counter
set label index of thisFile to 7
else
set problemFiles to problemFiles & {thisFile}
set label index of thisFile to 2
end if
on error
set problemFiles to problemFiles & {thisFile}
set this_data to problemFiles as text
set errorVar to (((path to desktop folder) as text) & "MastersLog")
my write_to_file(this_data, errorVar, true) --->Call to Log File SubRoutine
end try
set iteration to (iteration + 1) -- Progress Counter
end if
end tell
end timeout
end repeat
display dialog "All done." buttons {"OK"} default button 1 with icon 1 giving up after 10
if mycountcopied < total_count then display dialog "Some Items Were Not Copied They May Be Duplicates"
display dialog "Copied " & mycountcopied & " Files out of " & total_count & return & ¬
"JPEG's replaced with TIFF's: " & jpgToTiffExten