So, I have a folder with sub folders with files of different types (php,js,html). I would like to know if there is a command on windows powershell/cmd to save all files content of my directory into a single file. In brief, I would like to do a recursive cat > save.txt on windows.
Thank you in advance
>Solution :
Use Get-ChildItem
to recursively discover any files in the folder hierarchy, then pipe those to Get-Content
(for reading) and finally pipe the output from those calls to Set-Content
(for writing the whole thing back to disk).
Get-ChildItem path\to\root\folder -Recurse -File |Get-Content |Set-Content path\to\save.txt
Note: Unlike cat
, Get-Content
reads the files as text/strings by default, so this will work well for text-encoded files (like js, php and html source files), but won’t work on binary files