Program to auto-zip Files on a Server and File them Elsewhere on the Network

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510
Hello,

As a part of some weekly maintenance, I must check a web server for failed emails. I usually have to go into the folder on that server, compress/zip them, email them to myself and then file them away in a designated location for someone else to deal with.

I'd like to know if there was a way I can streamline this process. Maybe if there's a program out there that would automatically zip up these files in that folder on the web server and file them in the other designated folder on the network. Does anyone know what I could do for this or have anything in mind?
 
Solution
Wondering about three things now:

1) Where is the path to 7zip (7z.exe) as suggested by USAFRet? The script needs to know where to go to or look for the executable if I am following the requirements correctly. I.e., now located in Virtual 2008 RD Datacenter....

2) And also, in the script, why just 7z instead 7z.exe as has also been suggested?

3) Possible typo at the end of the current script - should be "Failed" and not "Faild" unless something has been changed.

And I am also going to correct myself - since you have spaces in the path names the quotes are needed.

Just some immediate observations..... will look at a couple of other things as the opportunity arises.
As @rgd1101 suggested - if that Web server is running on Linux, you can create a cron job to do that. A "script" in Unix/Linux is a text file containing a sequence of commands (much like DOS' BAT file), usually written in "shell".

You almost have to master one by yourself. I doubt you'll find ready-made script for that.
 
Also, with respect to the preceeding posts, if Linux is not available take a look at PowerShell.

Per Alabalcho's observation it is unlikely that you will find a ready made script.

You will need to write script in PowerShell that maps step by step to your manual process. Could be a bit daunting but doable.
 

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510
So I wrote the following script:

---------------------------------------------
@echo off
7za a -tzip "C:\Users\PBKAdmin\Dropbox\Failed Emails" "C:\Program Files (x86)\Persits Software\AspEmail\Queue\Failed"
pause

-----------------------------------------------

I installed 7Zip program on the server normally.

I get an error: '7za' is not recognized as an internal or external command, operable program or batch file.

I also tested pointing it to a folder on just C: and still didn't work.
 

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510


I have tried the actual path and 7z. It still does not work.
 

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510


Not sure what a lot of that does, but I did try without the quotes. It said it started, but still has the same error where '7z' is not recognized.

I also tried:
7z
7z.exe

- Both of those with/without quotes
- Both with full path, with/without quotes

I tried just two local folders without redirect and it just give me the same error.
 

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510


Current script:
---------------------------------------------------
@echo off
7z a -tzip "C:\Users PBKAdmin\Dropbox\Failed Emails" "C:\Program File (x86)\Persits Software\AspEmail\Queue\Faild"
pause

---------------------------------------------------

Error: '7z' is not recognized as an internal or external command, operable program or batch file.

I have tried without the quotes on one and both parameters.

- I got the download from www.7-zip.org/download.html (latest updated version)
- I picked the .exe 64-bit x64 version
- 7-Zip is installed on virtual 2008 R2 Datacenter, on the C: drive
- the "FolderSaver.bat" is saved on the root of C:
- I have the .bat set in a task scheduler (not that I think that matters)
- I have tried using the path of the 7z.exe as well (with/without quotes)
 
Wondering about three things now:

1) Where is the path to 7zip (7z.exe) as suggested by USAFRet? The script needs to know where to go to or look for the executable if I am following the requirements correctly. I.e., now located in Virtual 2008 RD Datacenter....

2) And also, in the script, why just 7z instead 7z.exe as has also been suggested?

3) Possible typo at the end of the current script - should be "Failed" and not "Faild" unless something has been changed.

And I am also going to correct myself - since you have spaces in the path names the quotes are needed.

Just some immediate observations..... will look at a couple of other things as the opportunity arises.
 
Solution

Nekrovar

Estimable
Mar 24, 2014
8
0
4,510


Looks like that worked.

Finished Code:
----------------------------------------------
@echo off
"C:\Program Files\7-zip\7z.exe" a -ztzip "C:\Users\PBKAdmin\Dropbox\Failed Emails" "C:\Program Files (x86)\Persits Software\AspEmail\Queue\Failed"
del /q "C:\Program Files (x86)\Persits Software\AspEmail\Queue\Failed\*"

----------------------------------------------

This works, however 7-Zip doesn't make it as nicely as I'd thought, but still accomplishes my goal. I now have Task Scheduler running this script once a week. On the other side of things, I will write another script to move from the location this one puts those failed emails to their proper location. I'm sure there is another way to do this, but this seemed the easiest route.

Thanks all who helped and hope someone else finds this useful.

The only problem I can see now is that if I'm not logged into the server or the dropbox on the server for it to work properly... I will have to test this out.