I would like to output the list of items in a folder in the folowing way:
\"filename1\" \"filename2\" \"file name with spaces\" \"foldername\" \"folder name wit
You can use the GNU ls option --quoting-style to easily get what you are after. From the manual page:
--quoting-style=WORDuse quoting style
WORDfor entry names:literal,locale,shell,shell-always,shell-escape,shell-escape-always,c,escape
For example, using the command ls --quoting-style=shell-escape-always, your output becomes:
'filename1' 'filename2' 'file name with spaces' 'foldername' 'folder name with spaces'
Using --quoting-style=c, you can reproduce your desired example exactly. However, if the output is going to be used by a shell script, you should use one of the forms that correctly escapes special characters, such as shell-escape-always.