I have the below folder structure, I want to zip all the files and folders within the folder.
Master Directory
File 1
File 2
SubFolder1
ABC Folder
file 1
XYZ Folder
file 1
And I'm using the below code, when I run it I am able to zip sub folders in the master directory and their sub folder and files. But not able to zip files inside the master directory.
CD /d D:\reports
for /d %%X in (*) do "C:\Program Files\7-Zip\7z.exe" a "D:\Report.zip" "%%X"
How to zip all the contents in the master folder. Any help will be appreciated.
Why not just:
"C:\Program Files\7-Zip\7z.exe" a "D:\Report.zip" "D:\reports\"
It will compress all files and subfolders inside D:\reports\ into D:\Report.zip.
If you don't want the top reports folder inside the zip but just the subfiles and subfolders, use this:
"C:\Program Files\7-Zip\7z.exe" a "D:\Report.zip" "D:\reports\*"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With