2013-06-09

Windows Powershell - Merge text files recursively, adding the name of each source file to each line in the consolidated file

Get-ChildItem -path C:\ORIGINAL_TEXT_FILES_FOLDER\n -recurse |?{ ! $_.PSIsContainer } |?{($_.name).contains(".txt")} | %{ Out-File -filepath C:\NEW_TEXT_FILE_PATH\CONSOLIDATED.txt -inputobject ($_.name + "|" + (get-content $_.fullname) + "`n" ) -Append}

No comments:

Post a Comment