error number -1700 from alias "Macin:2012:WK20:Free:Free_WK_20

I have taken this from a previous script, it used to collect the in formation from the desktop based on the folders on the desktop,

No I am trying to select a folder and then process the folder, the folder name is like this Brand_WK24_PSD.

You can see from the begining of the script that it extracts the information for filing the saved photoshop files.

and how to treat the files, as different brands have different script in photoshop so that the sizing is correct.

I have managed with some help already on the forum got the folder selection to work and get the information for folder labelling, however it can’t seam to process the files, its like they get by passed?

The error I get is this

→ error number -1700 from alias “Images:2012-2013:WK20:Freedom:Freedom_WK20_PSD:” to integer
open “Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt”
end tell

Here is the script so far.

property type_list : {"8BPS"}
property extension_list : {"psd"}
script o
          property theseNames : {}
end script
-- empty log file
do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
set noError to true
 
--at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
--use the result for the if file exists?
display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
set skipFiles to (button returned of the result) is "Skip (Faster)"
 
 
--Setup list of folders and process details of folders
tell application "Finder"
  
          set theFolder to (choose folder with prompt "Select Folder")
  
          set folderName to name of theFolder
  
  
  
          set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
          set FolderEndName to last text item of folderName
          set brandName to first text item of folderName
          set my text item delimiters to "_PSD"
          set weekNumber to first text item of FolderEndName
          set my text item delimiters to oldTID
  
  
  
  
  --set up names to destination folders and create locally based on brand name and week number
  
          set this_local_folder to "Images:2012-2013"
          set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
          set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
          set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
  
          set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
          set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
          set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
  
          set website_images to "DCKGEN:Website_Images:"
  
  --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
          set this_ftp_folder to "Impulse:"
          set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
          set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
          set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
          set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
  
  
  
  --taking the folder identify which process it must follow.
          if brandName is equal to "BH" then
                    try
                              tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                    on error
                              set o's theseNames to {} -- no psd files or "8BPS"
                    end try
  
                    set numOfNames to (count o's theseNames)
                    repeat with j from 1 to numOfNames
                              set thefile to theFolder & ":" & (item j of o's theseNames)
  --    B H     Folder Photoshop Process
  
                              set thisName to (item j of o's theseNames)
                              tell application "Finder"
                                        set t_ext to name extension of file thefile
                                        if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                        set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                              end tell
                              if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
  
                                        tell application "Adobe Photoshop CS5.1"
  -- I remove the command activate, Photoshop stay in background
                                                  set ruler units of settings to pixel units
  
                                                  try
  open (alias thefile) showing dialogs never
                                                            set origName to name of current document
                                                            set myOptions to {class:JPEG save options, quality:12}
                                                            set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
  
                                                            tell current document
  
  
  --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                      if (quick mask mode) then delete channel ¬
                                                                                "Quick Mask"
  --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                      if (exists layer "Original Layer") then ¬
                                                                                tell layer "Original Layer" to set name to "Original Image"
  save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                      (delete layer "Original Image") flatten
  
  resize image resolution 300 resample method none
  
  --sharpen image
  filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
  
  save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
  
  --Prepare for Low RES by resetting image history
                                                                      set current history state to history state 3
  
                                                                      flatten
  
                                                                      resize image width 1348
  resize image resolution 300 resample method none
  filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
  
  --add save to lowResFolder with same options
  save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
  
                                                                      set newFile to file path
                                                                      set newFile2 to newFile as string -- for testing end of name
                                                                      if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                      else
                                                                                my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
                                                                      end if
  
  close saving no
                                                            end tell
                                                  on error
                                                            set noError to false
                                                            my myLogs(thefile) -- write path to log file in Desktop
                                                            try
  close saving no --if exists, close current document
                                                            end try
                                                  end try
                                        end tell
                              end if
                    end repeat
  --End BH
  
  
 
  --taking the folder identify which process it must follow.  F R E E D O M   W I T H  P N G
          else if brandName is equal to "Freedom" then
                    try
                              tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                    on error
                              set o's theseNames to {} -- no psd files or "8BPS"
                    end try
  
                    set numOfNames to (count o's theseNames)
                    repeat with j from 1 to numOfNames
                              set thefile to theFolder & ":" & (item j of o's theseNames)
  --    F R E E D O M     Folder Photoshop Process W I T H  P N G
  
                              set networkBrandFolder_PNG to my getFolderPath("PNG", networkBrandFolder_Low_Res)
                              set networkBrandFolder_JPG to my getFolderPath("JPG", networkBrandFolder_Low_Res)
  
  
  
                              set thisName to (item j of o's theseNames)
                              tell application "Finder"
                                        set t_ext to name extension of file thefile
                                        if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                        set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                              end tell
                              if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
  
                                        tell application "Adobe Photoshop CS5.1"
  -- I remove the command activate, Photoshop stay in background
                                                  set ruler units of settings to pixel units
                                                  try
  open (alias thefile) showing dialogs never
                                                            set origName to name of current document
                                                            set myOptions to {class:JPEG save options, quality:12}
                                                            set myPNGOptions to {class:PNG save options, interlaced:false}
                                                            set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
  
                                                            tell current document
  
  --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                      if (quick mask mode) then delete channel ¬
                                                                                "Quick Mask"
  --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                      if (exists layer "Original Layer") then ¬
                                                                                tell layer "Original Layer" to set name to "Original Image"
  save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
  
                                                                      (delete layer "Original Image") flatten
  
  resize image resolution 300 resample method none
  
  --sharpen image
  filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
  
  save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
  
  --Prepare for Low RES by resetting image history
                                                                      set current history state to history state 3
  
  delete current layer
  merge visible layers
  
                                                                      resize image width 1020
  resize image resolution 300 resample method none
  filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
  
  --add save to lowResFolder with same options
  
  save in (networkBrandFolder_PNG & name) as PNG with options myPNGOptions without copying
                                                                      flatten
  save in (networkBrandFolder_JPG & name) as JPEG with options myOptions without copying
                                                                      set newFile to file path
  
  
  
                                                                      set newFile2 to newFile as string -- for testing end of name
                                                                      if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                      else
                                                                                save in (website_images & name) as JPEG with options myOptions without copying
  
                                                                      end if
  
  close saving no
                                                            end tell
                                                  on error
                                                            set noError to false
                                                            my myLogs(thefile) -- write path to log file in Desktop
                                                            try
  close saving no --if exists, close current document
                                                            end try
                                                  end try
                                        end tell
                              end if
                    end repeat
  --End F R E E D O M  W I T H  P N G 
  
  
  
 
  
          end if
  
  
end tell
if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
 
 
on myLogs(t)
          try
                    do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
          end try
end myLogs
 
 
on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
          tell application "Finder" to repeat with folderPath in foldersPath
                    with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
  duplicate tFile to folder folderPath with replacing
                    end timeout
          end repeat
end duplicateFile
 
 
on getFolderPath(tName, folderPath)
          tell application "Finder" to tell folder folderPath
                    if not (exists folder tName) then
                              return (make new folder at it with properties {name:tName}) as string
                    else
                              return (folder tName) as string
                    end if
          end tell
end getFolderPath
tell application "Finder"
          open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
end tell

Hi,

replace


open (alias thefile) showing dialogs never

with


open (file thefile) showing dialogs never

Same thing happening again

--> error number -1700 from alias "Images:2012-2013:WK20:Freedom:Freedom_WK20_PSD:" to integer
open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"

next try:

in this line


tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)

omit the specifier alias because theFolder is an alias

Still not running.

get folder “Freedom_WK20_HR” of folder “impulse:Week20:Freedom:”
→ “impulse:Week20:Freedom:Freedom_WK20_HR:”
get name of file (alias “Images:2012-2013:WK20:Freedom:Freedom_WK20_PSD:”) whose {“8BPS”} contains file type or {“psd”} contains name extension
→ error number -1700 from 1 to integer

I changed the line to look like this?

tell application “Finder” to set o’s theseNames to (name of file theFolder whose file type is in the type_list or name extension is in the extension_list)

Thanks for the quick responses!

no, omit means delete

tell application "Finder" to set o's theseNames to (name of theFolder whose file type is in the type_list or name extension is in the extension_list)

No error, but nothing happens?

get folder “Freedom_WK20_HR” of folder “impulse:Week20:Freedom:”
→ “impulse:Week20:Freedom:Freedom_WK20_HR:”
open “Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt”

as mentioned above, theFolder is of class alias, so you have to coerce it to text to append a filename


set thefile to (theFolder as text) & item j of o's theseNames

the line occurs two times in the script (as well as the other line to filter the files)

Still nothing, looking at what the script has done is only create the folders, then open the log file, looks like its completely skipping everything in between.

After it creates the relevant folders, it should be looking for brandname from the text of the selected folder then process in photoshop when it get a match.

I’m sure you know that already from the code, anyway.

To me it seams odd as before it would gather the information based on a collection of folders on the desktop. And then process the lot.

Still can’t see why its not picking it up and precessing

I recommend to use the log command and the Event Log Window to log variables at certain stages of the script.

I’d also remove the global Finder tell block and add tell application Finder to to the respective lines which use Finder terminology

Still lost by it all ,take it back to the original script and it appears to start to look at the items within the folder (but still does nothing)

This is the original script that looks at the desktop for the folders in the form of “Brand_WK24_PSD”, “Brand2_WK24_PSD” etc.

All i’m trying to do is specifically select a folder to process.

property type_list : {"8BPS"}
property extension_list : {"psd"}
script o
	property theseNames : {}
end script
-- empty log file
do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
set noError to true

--at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
--use the result for the if file exists?
display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
set skipFiles to (button returned of the result) is "Skip (Faster)"


--Setup list of folders and process details of folders


set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
set tc to (count dtF)
repeat with i from 1 to tc
	set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
	if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not start with "Sue" and folderName does not start with "Design" then
		
		set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
		set FolderEndName to last text item of folderName
		set brandName to first text item of folderName
		set my text item delimiters to "_PSD"
		set weekNumber to first text item of FolderEndName
		set my text item delimiters to oldTID
		
		set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
		
		
		--set up names to destination folders and create locally based on brand name and week number
		
		set this_local_folder to "Images:2012-2013"
		set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
		set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
		set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
		
		set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
		set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
		set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
		
		set website_images to "DCKGEN:Website_Images:"
		
		--set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
		set this_ftp_folder to "Impulse:"
		set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
		set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
		set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
		set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
		
		
		
		--taking the folder identify which process it must follow.
		if brandName is equal to "BHS" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    B H S    Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1348
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End BHS
			
			--taking the folder identify which process it must follow. B U R T O N
		else if brandName is equal to "Burton" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    B U R T O N    Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1020
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End B U R T O N
			
			--taking the folder identify which process it must follow. D A I S Y A N D E V E
		else if brandName is equal to "DaisyAndEve" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    D A I S Y A N D E V E    Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1280
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End D A I S Y A N D E V E
			
			--taking the folder identify which process it must follow. D O R O T H Y P E R K I N S
		else if brandName is equal to "DorothyPerkins" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    D O R O T H Y P E R K I N S    Folder Photoshop Process
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1000
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End D O R O T H Y P E R K I N S	
			
		else if brandName is equal to "Diva" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    D   I   V   A    Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1920
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			
			--taking the folder identify which process it must follow.  F R E E D O M   W I T H  P N G
		else if brandName is equal to "Freedom" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    F R E E D O M     Folder Photoshop Process W I T H  P N G
				
				set networkBrandFolder_PNG to my getFolderPath("PNG", networkBrandFolder_Low_Res)
				set networkBrandFolder_JPG to my getFolderPath("JPG", networkBrandFolder_Low_Res)
				
				
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPNGOptions to {class:PNG save options, interlaced:false}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								delete current layer
								merge visible layers
								
								resize image width 1020
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								
								save in (networkBrandFolder_PNG & name) as PNG with options myPNGOptions without copying
								flatten
								save in (networkBrandFolder_JPG & name) as JPEG with options myOptions without copying
								set newFile to file path
								
								
								
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									save in (website_images & name) as JPEG with options myOptions without copying
									
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End F R E E D O M  W I T H  P N G	
			
			
			--taking the folder identify which process it must follow. G I N A T R I C O T - I N T E R N A T I O N A L
		else if brandName is equal to "International" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    G I N A T R I C O T - I N T E R N A T I O N A L   Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								if (exists channel "Alpha 1") then ¬
									delete channel "Alpha 1"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1500
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End G I N A T R I C O T	
			
			--taking the folder identify which process it must follow. M A T A L A N 
		else if brandName is equal to "Matalan" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    M A T A L A N     Folder Photoshop Process
				
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPNGOptions to {class:PNG save options, interlaced:false}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								delete current layer
								merge visible layers
								
								resize image width 1000
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								
								save in (networkBrandFolder_Low_Res & name) as PNG with options myPNGOptions without copying
								flatten
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								set newFile to file path
								
								
								
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									save in (website_images & name) as JPEG with options myOptions without copying
									
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End M A T A L A N	
			
			--taking the folder identify which process it must follow. T O P M A N
		else if brandName is equal to "TopMan" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    T O P M A N     Folder Photoshop Process
				
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1020
								resize image resolution 300 resample method none
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End T O P M A N 
			
			--taking the folder identify which process it must follow. W A L L I S 
		else if brandName is equal to "Wallis" then
			try
				tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
			on error
				set o's theseNames to {} -- no psd files or "8BPS"
			end try
			
			set numOfNames to (count o's theseNames)
			repeat with j from 1 to numOfNames
				set thefile to theFolder & ":" & (item j of o's theseNames)
				--    W A L L I S     Folder Photoshop Process
				set thisName to (item j of o's theseNames)
				tell application "Finder"
					set t_ext to name extension of file thefile
					if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
					set b to exists file (localBrandFolder_PSD & thisName & ".psd")
				end tell
				if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
					
					tell application "Adobe Photoshop CS5.1"
						-- I remove the command activate, Photoshop stay in background
						set ruler units of settings to pixel units
						try
							open (alias thefile) showing dialogs never
							set origName to name of current document
							set myOptions to {class:JPEG save options, quality:12}
							set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
							
							tell current document
								
								--If the quick mask mode has been left on then delete the channel Quick Mask
								if (quick mask mode) then delete channel ¬
									"Quick Mask"
								--If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
								if (exists layer "Original Layer") then ¬
									tell layer "Original Layer" to set name to "Original Image"
								save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
								(delete layer "Original Image") flatten
								
								resize image resolution 300 resample method none
								
								--sharpen image
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
								
								--Prepare for Low RES by resetting image history
								set current history state to history state 3
								
								flatten
								
								resize image width 1020
								resize image resolution 300 resample method none
								filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
								
								--add save to lowResFolder with same options
								save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
								
								set newFile to file path
								set newFile2 to newFile as string -- for testing end of name
								if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
								else
									my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
								end if
								
								close saving no
							end tell
						on error
							set noError to false
							my myLogs(thefile) -- write path to log file in Desktop
							try
								close saving no --if exists, close current document
							end try
						end try
					end tell
				end if
			end repeat
			--End W A L L I S
			
		end if
	end if
end repeat
if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"


on myLogs(t)
	try
		do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
	end try
end myLogs


on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
	tell application "Finder" to repeat with folderPath in foldersPath
		with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
			duplicate tFile to folder folderPath with replacing
		end timeout
	end repeat
end duplicateFile


on getFolderPath(tName, folderPath)
	tell application "Finder" to tell folder folderPath
		if not (exists folder tName) then
			return (make new folder at it with properties {name:tName}) as string
		else
			return (folder tName) as string
		end if
	end tell
end getFolderPath
tell application "Finder"
	open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
end tell

again, use Event logging to monitor variable values

For example


set theFolder to choose folder
log theFolder

tell application "Finder" to set folderName to name of theFolder
log folderName

set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
set FolderEndName to last text item of folderName
set brandName to first text item of folderName
log brandName

set my text item delimiters to "_PSD"
set weekNumber to first text item of FolderEndName
log weekNumber

set my text item delimiters to oldTID

In AppleScript Editor press ⌘2 (Show Event Log) if the log window is hidden, then click on “Events”
The logged values are displayed in (* *)

Run the script, watch the log and you can compare the results with your expected values

OK back to the drawing board, and I think I have understood whatI need it to do looks like that its just the top I have a problem with.

Its on the verge of grabbing the files but somewhere in the code an extra : gets added

error “Finder got an error: Can’t get file "Images:2012-2013:WK18:Freedom:Freedom_WK18_PSD::FR10BW01341PK4PL.psd".” number -1728 from file “Images:2012-2013:WK18:Freedom:Freedom_WK18_PSD::FR10BW01341PK4PL.psd”

property type_list : {"8BPS"}
property extension_list : {"psd"}
script o
	property theseNames : {}
end script
-- empty log file
do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
set noError to true

--at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
--use the result for the if file exists?
display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
set skipFiles to (button returned of the result) is "Skip (Faster)"


--Setup list of folders and process details of folders

set AFolder to (choose folder with prompt "Select Folder")


log AFolder

tell application "Finder"
	set folderName to name of folder AFolder as text --<:  is the folder name, no need to use text item delimiters -->":"
end tell

log folderName
set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
set FolderEndName to last text item of folderName
set brandName to first text item of folderName
set my text item delimiters to "_PSD"
set weekNumber to first text item of FolderEndName
set my text item delimiters to oldTID

set theFolder to AFolder as string


--set up names to destination folders and create locally based on brand name and week number

set this_local_folder to "Images:2012-2013"
set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)

set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)

set website_images to "DCKGEN:Website_Images:"

--set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
set this_ftp_folder to "Impulse:"
set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)


In the original script you define the base folder with


set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)

theFolder contains a string path without trailing colon

in the other script the folder is defined with


set AFolder to (choose folder with prompt "Select Folder")
.
set theFolder to AFolder as string

choose folder returns an alias, the result of the coercion to string is a string path with a trailing colon

Search the script for a line where a literal colon is appended to a string path ( . & “:” & .)

You have been very helpful and patient

This line

set thefile to theFolder & “:” & (item j of o’s theseNames)

replaced with

set thefile to theFolder(item j of o’s theseNames)

its getting close but calls the error

tell application “AppleScript Editor”
theFolder(“FR10BW01341PK4PL.psd”)
→ error number -1708
Result:
error “«script» doesn’t understand the theFolder message.” number -1708 from «script»

one ampersand character is required

set thefile to theFolder & (item j of o's theseNames)

Ahhhhh VERY HAPPY NOW

Makes sense there should be an ambersand now!!

Once again many thanks!