OK here is the problem I am having - When I run this code I get an error on the Copy line at the bottom of the method. What the method does is get a list of all images in a folder. I can only have 5 images in the Normal folder before I have to start over with 5 more. (5 isn’t the real number, but if anyone tries to test they don’t want to test 99) Then I calculate the beginning and ending points of the array and move those files to the right folder. I then need to copy all of those files to another folder. That is where I am getting an error. This is a recurresive method so it calls itself.
The error is “Finder got an error: Can’t make some data into expected type” and it is highlighting the “Folder TheThumbFolder” in the copy line. I have tried making that variable a (TheThumbFolder as string) and (TheThumbFolder as alias) without any luck. I can’t get it and really need some help.
on ReworkFolderStructure(thestringFolder)
tell application "Finder"
set theAliasFolder to thestringFolder as alias
copy {(name of theAliasFolder)} to {MenuTitle}
end tell
if MenuTitle is not equal to "Template" then
tell application "Finder"
set these_files to every file of folder thestringFolder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
set these_folders to every folder of folder thestringFolder whose name does not start with "."
end tell
if (count of these_files) > 0 then
set NumberOfLoops to ((count of these_files) div 5)
set ExtraLoop to ((count of these_files) mod 5)
if ExtraLoop > 0 then
set NumberOfLoops to (NumberOfLoops + 1)
end if
repeat with i from 1 to NumberOfLoops
tell application "Finder"
set CreatedFolder to "Yes"
set theNUmberFolder to make new folder at folder thestringFolder as string with properties {name:"Section " & (i as string), comment:MenuTitle}
set theNewFolder to make new folder at theNUmberFolder as string with properties {name:"Normal", comment:MenuTitle}
set TheNewFXFolder1 to make new folder at folder (theNUmberFolder as string) with properties {name:"FX1", comment:MenuTitle}
set TheNewFXFolder2 to make new folder at folder (theNUmberFolder as string) with properties {name:"FX2", comment:MenuTitle}
set TheThumbFolder to make new folder at folder (theNUmberFolder as string) with properties {name:"Menus", comment:MenuTitle}
end tell
set x to ((i - 1) * 5) + 1
set y to (i * 5)
if (i = NumberOfLoops) then
tell application "Finder"
move (items x thru -1 of these_files) to theNewFolder
copy entire contents of folder theNewFolder to folder TheThumbFolder
end tell
else
tell application "Finder"
move (items x thru y of these_files) to theNewFolder
copy entire contents of folder theNewFolder to folder TheThumbFolder
end tell
end if
end repeat
end if
repeat with N from 1 to count of these_folders
set myItem to item N of these_folders
set folderToBeReworked to myItem as string
ReworkFolderStructure(folderToBeReworked)
end repeat
end if
end ReworkFolderStructure