Need batch for compressing and copying folders over network

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stan879nz
Posts: 1
Joined: 20 Feb 2016 06:52

Need batch for compressing and copying folders over network

#1 Post by stan879nz » 20 Feb 2016 07:43

Hello All

Problem:
My steam folder has become to big for the D: I need to swap it out for a bigger drive I will have to move it over the network to another device well I increase the drive

Folder Details:
-Total Folder Size: 878 GB (943,082,412,895 bytes)
-Total Folder File Count: 425,602 Files, 21,380 Folders

Drive Details:
-Capacity 931 GB
-Used: 888 GB
-Free: 43.4 GB

Network Speed:
-Backup Device: 10/100 mbps
-Source Device: 2x 1 gbps Link Aggregation "facepalm"

Thoughts
With the amount of files, the time in Handshakes alone is going to kill me. Then you have to factor in speeds being reset per file

Answers
1. I can .zip it all up with 0% comprssion then move it
2.I can ask for help in getting a batch to .zip each folder and copy it over the network one by one due to free space and this way have a decent backup for each folder only the folders in the pic or the common folder will need to be zipped and moved to nas

Pic
Image

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: Need batch for compressing and copying folders over network

#2 Post by mirrormirror » 21 Feb 2016 20:34

Hello, I didn't test the code below but copied/pasted from another script I've used. It should get you started. It uses 7-zip and the switches used here worked in v9.25 but should work in the latest version. You'll need 7z.exe in your path or in the folder where you launch the batch file. Good luck.

- REMOVE the "@ECHO" from the line that runs 7z.exe

Code: Select all

@ECHO OFF
REM change this to your source folder if batch file is not run from source folder
   SET myRoot=%~dp0
REM change this your your destination
   SET destination=c:\myfolder

FOR /F %%a IN ('DIR "%myroot%\" /ad /on /b') DO (
   CALL:do7z "%%a" "%destination%\%%a.7z"
)
GOTO:EndScript

:do7z
   REM -mx=0 - no compression. Change is needed (mx=9 is max)
   REM -spf = Store Full path - can remove is preferred
   REM -r = Recurse folders for archiving
   REM -m0=LZMA2 - compression type - can be changed if needed
   @ECHO 7z.exe u -r "%~2" "%~1\*" -spf -m0=LZMA2 -mx=0
GOTO:EOF

:EndScript

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need batch for compressing and copying folders over network

#3 Post by foxidrive » 22 Feb 2016 07:03

stan879nz wrote:2.I can ask for help in getting a batch to .zip each folder and copy it over the network one by one due to free space


Where will the zip files be created, and you mention backup so I presume you don't want them deleted after creation.

Do you want each folder zipped, then deleted, and then the file transferred immediately, and repeated for each common folder? If so then I'd recommend a full backup onto another drive to begin with - something could go wrong and your data will be gone.

Three backups of any data is really the minimum for a good backup strategy, if the data is valuable.

Post Reply