how to get path for multiple files correctly through applescript or through terminal
The selection in Finder returns a list, so here is an example of how I'd handle things:

Example AppleScript code:

tell application "Finder"
    set theSelection to selection
    if theSelection is {} then
        return
    else if (theSelection count) is equal to 1 then
        set thePathFilename to the quoted form of POSIX path of (theSelection as string)
    else
        set thePathFilename to {}
        repeat with i from 1 to (theSelection count)
            copy (quoted form of POSIX path of (item i of theSelection as string)) &amp; space to end of thePathFilename
        end repeat
        set thePathFilename to thePathFilename as string
    end if
end tell



If there is no selection when the script runs, it stops processing.
If only one item is in the selection, the thePathFilename contains one quoted POSIX Path Filename of the selected item, as a string.
If more then one item is in the selection, the thePathFilename contains the quoted POSIX Path Filename of each of the selected items, as a string, with a space after each.




Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.