How can I find a script for doing this works and many other similars ?
Contro, I'd like to offer some friendly advice, if I may. Spend some time learning a scripting language so tasks like these can be easily solved on your own (rather than waiting, potentially days, on forum replies).
Here's an example in AutoHotkey. Save this code to a .AHK file and then drag and drop one of your text files onto the .AHK file you created.
sFile = %1% ; Dropped filename path.
If ( sFile )
{
FileRead, myData, % sFile
Loop, Parse, myData, `n, `r
{
; Strip out extra whitespace.
myLine := RegExReplace( A_LoopField, ",\s+(\w)", ",$1" )
; Replace all commas with quotes-comma-quotes.
StringReplace, myLine, myLine, `,, "`,", All
; Rebuild file, adding quotes at the beginning and end
; of each line.
myBlock .= """" . myLine . """`r`n"
}
; Ask user to save file.
FileSelectFile, mySelectedFile, S16, % sFile, Save as...,
If ! ( ErrorLevel ) ; User did not cancel, proceed.
{
; Delete original and save new file. Yes, we should save
; to a temp folder and such but that's out of scope for this
; simple script.
If FileExist( mySelectedFile )
{
FileDelete, % mySelectedFile
If ( ErrorLevel ) ; Basic sanity check to see if the file deleted.
{
MsgBox, 16, Error!, Could not overwrite file. Exiting...
ExitApp
}
}
; Write file to disk.
FileAppend, % myBlock, % mySelectedFile
}
}
ExitApp