Automator: Applescript to execute keystrokes for each nested folder in Finder
If I understood what you want, i.e. select a folder and then it and every sub-folder within it, including sub-folders of subfolders etc., gets these setting applied.

In order to pass the keystrokes to the target folders each needs to be the active window in Finder first, then System Events can send the keystrokes.

So, I'd write the code as in the example below.

tell application "Finder"
    activate
    set parentFolder to (choose folder) as alias
    set theFolders to every folder of entire contents of parentFolder as alias list
    set theFolders to {parentFolder} &amp; theFolders    -- # Adds the chosen folder to the list of folders to be acted upon.
    repeat with eachFolder in theFolders
        open eachFolder
        delay 0.5
        activate eachFolder    -- # This is done to ensure the target folder's window has focus before being acted upon.
        tell application "System Events"
            keystroke "2" using {control down, command down}    -- # Sets: View &gt; Arrange By &gt; Kind
            keystroke "1" using {control down, option down, command down}    -- # Sets: View &gt; Sort By &gt; Name
        end tell
        close eachFolder
    end repeat
end tell




If you're wanting to act only on the top level sub-folders within the parent folder, then in place of: 

set theFolders to every folder of entire contents of parentFolder as alias list

Use the following:

set theFolders to every folder of parentFolder as alias list    




Note that the delay 0.5 may not be absolutely necessary however I added it because without it, the series of opening and closing folder's windows can go by so fast it's disconcerting and slowing it down a bit eases that. Although it may also be necessary, depending on how fast/slow the processing takes place, to ensure each folder's window in the repeat loop is actually available and has focus in order to receive the keystrokes. In either case, the value of delay may/can be changed as necessary/wanted to allow the tasks to properly occur and in a visual manner that appears more natural then a barrage of opening/closing windows leaving one to wonder, what just happened.