Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Save all files content from a directory and sub directory into a single file with Windows cmd/Powershell

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading