Making a list from do shell script find response

I am not sure what I am doing wrong. Trying to generate a new list with added text to each file path that is returned from a do shell script find of a specific file type. My goal is to search a group of selected folders make a list folder paths with added arguments then make another do shell script command from the concatenated paths/arguments. For some reason when I do the repeat in this script it only gives me the last file in the sequence of say 100 image frames within a folder.

Any help would be greatly appreciated. Sure it is silly but been stuck on it for two days.


set camSrc to (choose folder with prompt "Choose Camera Source Folder:")
-- choose original camera footage
set folderNPosix to text 1 thru -2 of (POSIX path of (result))
set fileType to {"exr"}
listFilesByExt(fileType, folderNPosix)



on listFilesByExt(fileType, folderNPosix)
	
	set expr to quoted form of ("*." & fileType as string)
	set fileList to paragraphs of (do shell script "find -L " & folderNPosix & " -name " & expr)
	--get all the files with exr file extension from selected folder
	set tid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ","
	set newFileList to text items of fileList
	set AppleScript's text item delimiters to tid
	
	
	repeat with i from 1 to count of newFileList
		set lftEyeString to make list of ("left " & item i of newFileList)
	end repeat
	lftEyeString
	
end listFilesByExt

Model: MacBook Pro
AppleScript: 2.3
Browser: Safari 537.71
Operating System: Mac OS X (10.8)

Hi pig_fly,

 set fileList to paragraphs of (do shell script "find -L " & folderNPosix & " -name " & expr)

fileList is already a list and not a comma delimited string.

gl,
kel

Thanks kel1.
When I made the change below it still only gave me a result of the last file in list not the entire list of files.
Any ideas?

Thanks again.


set camSrc to (choose folder with prompt "Choose Camera Source Folder:")
-- choose original camera footage
set folderNPosix to text 1 thru -2 of (POSIX path of (result))
set fileType to {"exr"}
listFilesByExt(fileType, folderNPosix)



on listFilesByExt(fileType, folderNPosix)
	
	set expr to quoted form of ("*." & fileType as string)
	set fileList to paragraphs of (do shell script "find -L " & folderNPosix & " -name " & expr)
	--get all the files with exr file extension from selected folder
	
	repeat with i from 1 to count of fileList
		set lftEyeString to ("left " & item i of fileList)
	end repeat
	lftEyeString
	
end listFilesByExt

You need to gather up all your changes into a new list if that’s what you want:

set camSrc to (choose folder with prompt "Choose Camera Source Folder:")
-- choose original camera footage
set folderNPosix to text 1 thru -2 of (POSIX path of (result))
set fileType to {"exr"}
listFilesByExt(fileType, folderNPosix)



on listFilesByExt(fileType, folderNPosix)
	
	set expr to quoted form of ("*." & fileType as string)
	set fileList to paragraphs of (do shell script "find -L " & folderNPosix & " -name " & expr)
	--get all the files with exr file extension from selected folder
	set newList to {}
	repeat with i from 1 to count of fileList
		set lftEyeString to ("left " & item i of fileList)
		set end of newList to iftEyeString
	end repeat
	return newList
	
end listFilesByExt

Thank you very much!!

Just for the record: File names can contain new lines in their names.

So, have been playing around with the script a little more and was wondering if you guys could clarify something for me. Just want to understand it better.

Why is there a need to write " set end of newList to lftEyeString"? Know its very basic but read tutorial on power of lists and it still hasn’t clicked for me.

And then how would I change the script just in case a filename had a new line in its name.

Thanks again. Learning as I go and this site in so much help.

Hi,

The only item I have ever seen that takes up two lines is the icon file. But, I’m quite sure that the find command doesn’t list dot files or invisible files. Not sure.

Edited: I think it’s faster to append to a list than to concatenate. That’s why you use the ‘set’ end of. Not sure if Apple made it irrelevant by now, so it could be just habit.