automatization with powershell Start-Process

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

automatization with powershell Start-Process

Erhy
Hallo!
 My task is, to convert many files encoding in latin1 to UTF-8

I know the sequence which works:

open a file
set set fileencoding=utf-8
set bomb
wrtite to another file

but there are problems with the argument list
this fails:
Start-Process -FilePath 'C:/Program Files (x86)/Vim/vim82/vim.exe' -wait -ArgumentList ('"S:\testConcToUTF2\b Ansi copied.txt"', '-c set fileencoding=utf-8')


please give me an advice
Erhy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/296f99c8-f209-483d-8f1b-21604e5a1302%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: automatization with powershell Start-Process

skeept


On Friday, January 17, 2020 at 4:01:09 PM UTC-6, Erhy wrote:
Hallo!
 My task is, to convert many files encoding in latin1 to UTF-8

I know the sequence which works:

open a file
set set fileencoding=utf-8
set bomb
wrtite to another file

but there are problems with the argument list
this fails:
Start-Process -FilePath 'C:/Program Files (x86)/Vim/vim82/vim.exe' -wait -ArgumentList ('"S:\testConcToUTF2\b Ansi copied.txt"', '-c set fileencoding=utf-8')


I think the only think you need to change is the last part:

'-c set fileenconding=utf-8' should be changed to

'-c', '"set fileencoding=utf-8"'

 

please give me an advice
Erhy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4bf96bae-3892-45ac-af52-d0a4ee0706e0%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: automatization with powershell Start-Process

Erhy
Thank you, this works!
 

'-c set fileenconding=utf-8' should be changed to

'-c', '"set fileencoding=utf-8"'

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5111ec91-06c7-448f-8615-089121aff6f8%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: automatization with powershell Start-Process

Erhy
In reply to this post by skeept
Thank you it worked

Here an example of the full command to convert encoding to UTF-8 with BOM

Start-Process -FilePath 'C:/Program Files (x86)/Vim/vim82/vim.exe' -wait -ArgumentList ('"S:\testConcToUTF2\b Ansi copied.txt"', '-c', '"set fileencoding=utf-8"', '-c', '"set bomb"', '-c', '"w S:/testConcToUTF2/b Ansi copied now UTF.txt"', '-c', '"q!"' )

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/cbc83990-fe51-42b4-b7f8-fded174466c7%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: automatization with powershell Start-Process

Erhy
and now a better Start-Process which don't flicker:

    $argRead = '"e ' + $filename + '"'
    $argwrite
= '"w! ' + $tmpFilepath + '"'
   
Start-Process -FilePath $vimPath -wait -WindowStyle Hidden -ArgumentList ( `
        '-c', '"set noswapfile"', '-c', $argRead, `

       
'-c', '"set fileencoding=utf-8"', '-c', '"set bomb"', `
        '-c', $argwrite, '-c', '"q!"' )



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5acb20fb-7fe9-4cac-b970-97e826f18c54%40googlegroups.com.