Ok, here’s the jist of what I am trying to do. We have a field laptop that will be receiving data from a monitor on a offshore rig. All that data will be dumped into a single folder, no sub directories, on it’s c drive. It then needs to be compressed and copied over to a server in our clients domain. Ok, that’s easy. What is difficult is that they need a compressed file for each day. As in, everyday only zip up the new data and copy that newly created zip to the server. I can’t seem to get 7zip to only compress new files in my test environment. I am pretty new to scripting, so I know I’m just missing something simple.

So once again, I need the script to compress newly created files on the current date, then copy those to a server. The next day I need it to copy on tomorrow’s newly created data files and compress and send them.

Confused? Sorry…

Here’s my script:

@echo off
For /f "tokens=2-4 delims=/ " %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b)
net use \localhost\ipc$
net use h: \server\source_folder /user:username password
7z u -mx9 “c:\Source\Company_name_%mydate%.7z” “c:\Source”
robocopy c:\Source h:\ .7z /XF /COPY:DAT /V /XO /NJH /NP /LOG+:“h:\tranfer.log” /R:1000 /W:10 /MOV
c:
net use \localhost\ipc$ /del
net use h: /del /y

4 Spice ups

In Robocopy can you have it create a %date% subfolder and then use 7zip to only zip the %date% subfolder?

I’m not too familiar with Robocopy, I know using xcopy it would be as simple as that though.

GENIUS!!! I LOVE SW!!!

I’ve been hassling with this for about 2 hours now! All it took was a 10 minute submission on Spiceworks and BOOM! Thanks Brandon.A! I added the mkdir c:\source%mydate% to the script followed by Robocopy to move all the contents of C:\source to C:\source%mydate%. That allows me to tell 7zip to compress only the C:\source%mydate% creating only 1 archive in c:source and then robocopy will move all .7z files to the server! BRILLIANT!

Here’s what I added following your advice:

@echo off
For /f "tokens=2-4 delims=/ " %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b)
net use \localhost\ipc$
net use h: \server\source_folder /user:username password

mkdir c:\Source%mydate%
robocopy c:\Source c:\Source%mydate% /COPY:DAT /V /XO /NJH /NP /R:1000 /W:10 /MOV

7z u -mx9 “c:\Source\Company_name_%mydate%.7z” “c:\Source”
robocopy c:\Source h:\ .7z /XF /COPY:DAT /V /XO /NJH /NP /LOG+:“h:\tranfer.log” /R:1000 /W:10 /MOV
c:
net use \localhost\ipc$ /del
net use h: /del /y

Sometimes all it takes is a fresh set of eyes :slight_smile: Glad it worked!