In finder, we can 'arrange by' for each folder separately, but how to set these settings for all folders.
NOTE: i have tried 'Use as defaults' in info dialog but of no use
To answer your first question, this isn't a script, but it is a procedure you can follow to make all Finder windows sorted by name. Open a Finder window. Select a regular folder; not a pseudo-folder (the Use as defaults button does not appear on Airdrop or Recents). Press Command-J. In the Sort By drop-down control, select Name. Click the Use as defaults button at the bottom of the window.
For the second, no, "sort by" sorts everything, including folders. If there are particular files or folders you want at the top of the list, you could start their name with a space, but don't do that to folders that applications or the system expect to have particular names. It does work for folders you create within your own Documents directory, however.
You can use TotalFinder to do this.
Unfortunately, I don't know of any scripts that can arrange all files in EVERY folder by name, or scripts to keep the folders at the top, but you can sort your files by type (extensions, alphabetically), and by name through right clicking (Control-click) in your folder (not selecting any specific file), and select Clean up by -> Kind or Name.