choose folder and get file path for folders inside

I must be having a brain malfunction…

so here is my problem. We manipulate many images all the time and I want a user to select a folder (this folder will contain 5 other folders) I want to get the path for the selected folder and then use that path to get to the rest of the folders later in my script.

basically here is the simple form of what I have now.


set folderOne to choose folder with prompt "Select the Product Images Final Folder!" --folder with 5 folders inside
set folderTwo to choose folder with prompt "Select the corrected image folder!" -- this is a folder for file comparison later
set this_folder to (path to desktop folder)
tell application "Finder"
	set myFile to get POSIX path of folderOne
	set newFile to folderLG & "Large" -- appended file path to get the large folder inside of folderOne
	set copyFiles to every file in folder newFile  --problem starts here, says it cant get every file in this folder
	duplicate copyFiles to the folder "missing images" of this_folder replacing yes -- this does the copying of files
end tell

can anyone help to get the main folder path and use it to append the name of the inside path?

I hope this is clear???

thanks, for all the help in advance. This site is the BEST!

Scott

Hello.

I’m not totally sure of what you want, folders for comparing etc.
The snippet below, would copy files correctly if this_folder was specified with a valid hfs name, and the folder
“missing images” existed within that.
Try to work it out from here. The script uses file references internally, not aliases. a file reference is an object specifier which has the form: file “Macintosh Hd:Users:You:Desktop:TestFolder:” for instance.


tell application "Finder"
	set baseFolders to every folder of (choose folder)
	repeat with aFolder in baseFolders
		set copyFiles to every file in aFolder
		repeat with aFileToBeCopied in copyFiles
			duplicate aFileToBeCopied to the folder "missing images" of this_folder replacing yes -- this does the copying of files	
		end repeat		
	end repeat
end tell



“user error” :smiley:

‘folderLG’ is unknown to the script.
And if it were known it would probably be a path, not a string.
Assuming ‘folderLG’ ¢is¢ known you’d say this:

set newFile to ((folderLG as string) & "Large:") as alias -- only works when item exists!
-- note trailing colon to make it a folder

This is cleaner:

set folderLG to folder "Large" of folder folderOne

Thanks guys this is exactly what I was looking for.

@allastor933

Clean and simple, works great to get the needed folder. I knew my brain just was not working!

Thanks,
Scott