Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Specify the directory path
- $directoryPath = "C:\Folder with your merged files"
- # Get all text files in the specified directory
- $textFiles = Get-ChildItem -Path $directoryPath -Filter *.txt
- # Process each text file
- foreach ($file in $textFiles) {
- # Read the content of the file
- $content = Get-Content -Path $file.FullName -Raw
- # Remove the last space from the content
- $content = $content.TrimEnd()
- # Write the modified content back to the file
- $content | Set-Content -Path $file.FullName -NoNewline
- }
- Write-Host "Operation complete. Last space removed from text files in $directoryPath."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement