# batch file to copy files from last month to archive it.



## Samsunlu (Apr 12, 2010)

Hi all,

I need a batch file (code) to copy files from last month and zip it for archive. Can somebody help me please?

Thanks!
Samsunlu


----------



## Squashman (Apr 4, 2003)

Are these files all sitting on one folder or are they spread out across a nested directory structure?
What cmd line zip program are you using?


----------



## Samsunlu (Apr 12, 2010)

Hi Squashman,

Thanks for responding so quick!

These are files in different folders. And I'm using 7z to zip the files.


----------



## Squashman (Apr 4, 2003)

Are they in a BASE folder and nested from there or are we going to have to search the whole hard drive?
Are we working off of created or modified date?


----------



## Samsunlu (Apr 12, 2010)

We don't need to search the whole hard drive.

What I need is:

Everyday we create files and process them. After the processing I have to archive the files.
They are not in one folder but in 2 folders with a couple sub folders on one server.

Before I manually copied the files into an other server and zipped them manually on a monthly base (sorted by created date).
But this takes much time for me so I'm working on / looking for a script to automate this process.

I hope you understand my question?
My English is not perfect (I'm Dutch...)

Thanks!


----------



## Squashman (Apr 4, 2003)

So you have something like this. Basically two base folders with nested subfolders.

```
C:.
&#9500;&#9472;&#9472;&#9472;Folder1
&#9474;   &#9474;   file1.txt
&#9474;   &#9474;   file2.txt
&#9474;   &#9474;   
&#9474;   &#9500;&#9472;&#9472;&#9472;Subfolder1
&#9474;   &#9474;       File3.txt
&#9474;   &#9474;       file4.txt
&#9474;   &#9474;
&#9500;&#9472;&#9472;&#9472;Folder2
&#9474;       foo1.txt
&#9474;       foo2.txt&#9474;
```
Where is the archive going to be placed? I would assume outside of this folder structure otherwise you may end up archiving the archive.

I would assume this would run the first of the month. So when May 1st comes around you will want it to archive all files that were created in April in the two base folders. What do you want to do with the files after they are archived? Do you want them deleted from the two base folders? If you remove all the files from a nested folder do you want the folder removed as well?


----------



## Samsunlu (Apr 12, 2010)

Thanks Squashman, this is exactly my situation.

In C:\Folder1\Done I have a couple of subfolders (C:\Folder1\export, C:\Folder1\Import etc).
In C:\Folder2 I also have subfolders and al lot files to be archived.

I want the archiving process to start the first of the month indeed. Your example is correct (start the archive process on May 1st, all files created in April should be archived).

And I want the files to be zipped after archiving to an other location (server).

The original files in C:\Folder1 and Folder2 can be deleted.

Thanks!!


----------

