DonationCoder.com Software > Finished Programs
DONE: Append/Concatenate/Merge text files, but prepend filenames
nkormanik:
Any suggestions on the best way to append/concatenate/merge text files, and include filenames (and paths, even better) separating the files.
I've regularly simply used 'copy':
copy *.txt bigfile
But this, of course, does not include filenames between files.
Thoughts appreciated.
Thanks!
Nicholas Kormanik
c.gingerich:
@nkormanik Yep I can whip up a quick app. :Thmbsup:
4wd:
--- Code: PowerShell ---Get-ChildItem ..\*.ps1 | ForEach-Object { Add-Content -Path 'output.txt' "`r`n----------`r`n$($_.FullName)`r`n----------"; Add-Content -Path 'output.txt' -Value (Get-Content $_.Fullname) }
Output:
--- Code: Text -------------Z:\test\Base64Encode.ps1----------$Content = Get-Content -Path K:\favicon.ico -Encoding Byte$Base64 = [System.Convert]::ToBase64String($Content)$Base64 | Out-File K:\encoded.txt ----------Z:\test\concat.ps1----------Get-ChildItem ..\*.ps1 | ForEach-Object { Add-Content -Path 'output.txt' "`r`n----------`r`n$($_.FullName)`r`n----------"; Get-Content $_ | Out-File 'output.txt' -Append -Encoding utf8 } ----------Z:\test\Detect-Computers.ps1----------Ping 192.168.0.255arp -a | select-string 'dynamic' | foreach {$_.line.trim().split(" ") | select -first 1 } | foreach {(Resolve-DnsName -Name $_ -ea 0).namehost}(Test-Connection SABnzbd -Quiet -Count 1)
c.gingerich:
@nkormanik
Give this a try. Extract and run MergeTXT.exe. Drag drop plain text files on to the dialog, set an output file, and click Go. You can optionally set the file name as the separator between text in the output file.
There currently is no way to reorder the files in the list other than how you drop them on the dialog and you can also click on the "File" header in the list to sort them A-Z or Z-A. If this works well for you then I'll add a way to reorder the files [buttons to move the file up or down in the list].
https://filedn.com/lx9UK6VkCuXBk4O2YliWIkY/MergeTXT.zip
wraith808:
--- Code: PowerShell ---Get-ChildItem ..\*.ps1 | ForEach-Object { Add-Content -Path 'output.txt' "----------`r`n$($_.FullName)`r`n----------`r`n"; Get-Content $_ | Out-File 'output.txt' -Append -Encoding utf8 }
Output:
--- Code: Text -------------Z:\test\Base64Encode.ps1----------$Content = Get-Content -Path K:\favicon.ico -Encoding Byte$Base64 = [System.Convert]::ToBase64String($Content)$Base64 | Out-File K:\encoded.txt ----------Z:\test\concat.ps1----------Get-ChildItem ..\*.ps1 | ForEach-Object { Add-Content -Path 'output.txt' "`r`n----------`r`n$($_.FullName)`r`n----------"; Get-Content $_ | Out-File 'output.txt' -Append -Encoding utf8 } ----------Z:\test\Detect-Computers.ps1----------Ping 192.168.0.255arp -a | select-string 'dynamic' | foreach {$_.line.trim().split(" ") | select -first 1 } | foreach {(Resolve-DnsName -Name $_ -ea 0).namehost}(Test-Connection SABnzbd -Quiet -Count 1)-4wd (October 03, 2018, 07:48 AM)
--- End quote ---
Google again? You have me wanting to use powershell for more than I use it for...
Navigation
[0] Message Index
[#] Next page
Go to full version