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.<\/p>\n
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.<\/p>\n
Confused? Sorry…<\/p>\n
Here’s my script:<\/p>\n
@echo<\/span> off In Robocopy can you have it create a %date% subfolder and then use 7zip to only zip the %date% subfolder?<\/p>\n I’m not too familiar with Robocopy, I know using xcopy it would be as simple as that though.<\/p>","upvoteCount":0,"datePublished":"2011-10-25T13:48:42.000Z","url":"https://community.spiceworks.com/t/need-help-with-a-7zip-robocopy-script/108943/2","author":{"@type":"Person","name":"superbrandon","url":"https://community.spiceworks.com/u/superbrandon"}},"suggestedAnswer":[{"@type":"Answer","text":" 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.<\/p>\n 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.<\/p>\n Confused? Sorry…<\/p>\n Here’s my script:<\/p>\n @echo<\/span> off GENIUS!!! I LOVE SW!!!<\/strong><\/p>\n I’ve been hassling with this for about 2 hours now! All it took was a 10 minute submission on Spiceworks and BOOM!<\/strong> 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!<\/p>\n Here’s what I added following your advice:<\/p>\n @echo<\/span> off mkdir c:\\Source%mydate%<\/strong> 7z u -mx9 “c:\\Source\\Company_name_%mydate%.7z” “c:\\Source” Sometimes all it takes is a fresh set of eyes
\nFor /f \"tokens=2-4 delims=/ \" %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b)
\nnet use \\localhost\\ipc$
\nnet use h: \\server\\source_folder /user:username password
\n7z u -mx9 “c:\\Source\\Company_name_%mydate%.7z” “c:\\Source”
\nrobocopy c:\\Source h:\\ .7z<\/em> /XF /COPY:DAT /V /XO /NJH /NP /LOG+:“h:\\tranfer.log” /R:1000 /W:10 /MOV
\nc:
\nnet use \\localhost\\ipc$ /del
\nnet use h: /del /y<\/p>","upvoteCount":4,"answerCount":4,"datePublished":"2011-10-25T13:45:51.000Z","author":{"@type":"Person","name":"danielcantu8811","url":"https://community.spiceworks.com/u/danielcantu8811"},"acceptedAnswer":{"@type":"Answer","text":"
\nFor /f \"tokens=2-4 delims=/ \" %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b)
\nnet use \\localhost\\ipc$
\nnet use h: \\server\\source_folder /user:username password
\n7z u -mx9 “c:\\Source\\Company_name_%mydate%.7z” “c:\\Source”
\nrobocopy c:\\Source h:\\ .7z<\/em> /XF /COPY:DAT /V /XO /NJH /NP /LOG+:“h:\\tranfer.log” /R:1000 /W:10 /MOV
\nc:
\nnet use \\localhost\\ipc$ /del
\nnet use h: /del /y<\/p>","upvoteCount":4,"datePublished":"2011-10-25T13:45:51.000Z","url":"https://community.spiceworks.com/t/need-help-with-a-7zip-robocopy-script/108943/1","author":{"@type":"Person","name":"danielcantu8811","url":"https://community.spiceworks.com/u/danielcantu8811"}},{"@type":"Answer","text":"
\nFor /f \"tokens=2-4 delims=/ \" %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b)
\nnet use \\localhost\\ipc$
\nnet use h: \\server\\source_folder /user:username password<\/p>\n
\nrobocopy c:\\Source c:\\Source%mydate% /COPY:DAT /V /XO /NJH /NP /R:1000 /W:10 /MOV<\/strong><\/p>\n
\nrobocopy c:\\Source h:\\ .7z<\/em> /XF /COPY:DAT /V /XO /NJH /NP /LOG+:“h:\\tranfer.log” /R:1000 /W:10 /MOV
\nc:
\nnet use \\localhost\\ipc$ /del
\nnet use h: /del /y<\/p>","upvoteCount":0,"datePublished":"2011-10-25T14:05:05.000Z","url":"https://community.spiceworks.com/t/need-help-with-a-7zip-robocopy-script/108943/3","author":{"@type":"Person","name":"danielcantu8811","url":"https://community.spiceworks.com/u/danielcantu8811"}},{"@type":"Answer","text":" Glad it worked!<\/p>","upvoteCount":0,"datePublished":"2011-10-26T05:36:16.000Z","url":"https://community.spiceworks.com/t/need-help-with-a-7zip-robocopy-script/108943/4","author":{"@type":"Person","name":"superbrandon","url":"https://community.spiceworks.com/u/superbrandon"}}]}}