Good day to all.
I want to take each file from a specified folder and then run a program that will use each file in turn.
in the example, notepad++ opens for me, but there is a problem with names that have a space, and in general it seems to me that the code is not quite correct.
help me please
$path = "C:\temp\*"
# Show all files in the folder
Get-ChildItem -Path $path | Where-Object {
!$_.PSIsContainer -and $_.Extension -eq ".xml"
} |
Foreach-Object { Start-Process -FilePath "C:\Program Files\Notepad++\notepad++.exe" -ArgumentList $_.FullName }
The result depends on the program you want to run and on the amount of files you want to process. If the file extension is linked to the proper program you could use Invoke-Item instead of Start-Process.
Thanks Olaf, but the problem with the space in the name is not solved here, I have a file there, for example, which is called “1 (2).xml” and when opened it says that file 1 does not exist, create it? file (2).xml does not exist, create?