I need to run a command through PowerShell (through Stata). The command works fine as when I open shell through Stata and then copy and paste the command in, it works. However if I run the command from Stata with shell at the beginning it gives me a strange error.
The code I run:
The error I get:
I'm not sure if this is a Stata question as the error comes from PowerShell, but I was thinking maybe the Stata shell command is the culprit.
The code I run:
Code:
shell powershell.exe -noexit -command " dir 'C:\Documents\Newfolder' -Filter '*.txt' | ForEach-Object { (Get-Content $_.FullName) | ForEach-Object { $_ -replace '""', '' } | Set-Content $_.FullName }"
Code:
Get-Content : Cannot find path 'C:\Documents\Newfolder\.FullName' because it does not exist. At line:1 char:90 + ... Each-Object { (Get-Content .FullName) | ForEach-Object { -replace '"', '' } | S ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Documents...older\.FullNa me:String) [Get-Content], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo ntentCommand
I'm not sure if this is a Stata question as the error comes from PowerShell, but I was thinking maybe the Stata shell command is the culprit.
Comment