

If the batch file is in the same directory then you don't need to add the path, this will just change the extension but if you want to keep original you will need to put them in another directory. You will not have to change the filename only the extension. If the file extension is changed to "csv" then excel will try to load it but it does require the delimiters to split it into the relevant cells like ", ". Also each new line will change to another row in excel. The comma's determine how excel will split the two messages into different cells. Unfortunately excel will need some king of way to determine the cells for example This is a line of text, This is another line of text $NewFilepath = "$($file.BaseName).First of all is the data comma delimited or some other form. basename would remove that complexity in other areas as well. I know that you are dealing with txt files, so you already know how many characters on the end to remove, but using. File objects have a basename property that is the file name without the extension. This is what you are doing to replace the extension of the file. $fileGroups = 0.($numberOfGroups - 1) | Foreach-object$" $maxGroupMemberSize = ::Ceiling($files.Count / $numberOfGroups) For Each group and excel process will be started. # Split the files up into processing groups.

$files = Get-ChildItem -Path $path -Filter "*.txt" -File $currentExcelProcessIDs = (Get-Process excel -ErrorAction Silentl圜ontinue).Id # Silentl圜ontinue in case there are no active Excels # Get Current EXCEL Process ID's so they are not affected but the scripts cleanup Some comments in the code below explain it more. Each group will be past to its own Excel job for processing. What this will do is group up identified files. I am going to show an approach using Jobs. PowerShell does support multiple avenues of mitigating this Processing 10's of 1000's of files with one Excel instance will be draining. Running the com object is dragging in itself.

As far as performance goes there are two general approaches to address this Parallel processing
