Copy full directory using command prompt and make zip

Опубликовано: 17 Октябрь 2024
на канале: TechFouls
1,923
1

Hello all,

In this video you can see how to copy all the files and folder from source to destination using command prompt and make it zip day wise.

One more functionality is given in the video is of backup folder days wise i.e.
Day 1 : 26.12.2016
Day 2 : 27.12.2016
Day 3 : 28.12.2016
Day 4 : 29.12.2016
Day 5 : 30.12.2016
Day 6 : 31.12.2016 (On the sixth day the day 1 folder will be deleted)

You can keep this file in your scheduler and can take backup with click any file.

Thank you for watching video.

--code starts here---

D:
cd Abhi
cd Test2
set now=%date:~-4,4%%date:~-7,2%%date:~-10,2%
mkdir %now%

set sourceFolder="D:\Abhi\Test1"
set destFolder="D:\Abhi\Test2\%now%"

xcopy %sourceFolder% %destFolder% /S /Y /R


ForFiles /P D:\Abhi\Test2 /D -5 /C "CMD /C if @ISDIR==TRUE echo RD /Q @FILE &RD /Q /S @FILE"

powershell.exe -nologo -noprofile -command "& {Add-Type -A 'System.IO.Compression.FileSystem'; If(Test-path 'D:\Abhi\Test2\%now%Abhi.zip') {Remove-item 'D:\Abhi\Test2\%now%Abhi.zip'}; [io.compression.zipfile]::CreateFromDirectory('D:\Abhi\Test2\%now%', 'D:\Abhi\Test2\%now%Abhi.zip');}"

--code ends here---