1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Software Development' started by Samsunlu, Apr 12, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. Samsunlu

    Samsunlu Thread Starter

    Joined:
    Apr 12, 2010
    Messages:
    4
    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
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    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?
     
  3. Samsunlu

    Samsunlu Thread Starter

    Joined:
    Apr 12, 2010
    Messages:
    4
    Hi Squashman,

    Thanks for responding so quick!

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

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    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?
     
  5. Samsunlu

    Samsunlu Thread Starter

    Joined:
    Apr 12, 2010
    Messages:
    4
    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!
     
  6. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    So you have something like this. Basically two base folders with nested subfolders.
    Code:
    C:.
    ├───Folder1
    │   │   file1.txt
    │   │   file2.txt
    │   │   
    │   ├───Subfolder1
    │   │       File3.txt
    │   │       file4.txt
    │   │
    ├───Folder2
    │       foo1.txt
    │       foo2.txt│
    
    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?
     
  7. Samsunlu

    Samsunlu Thread Starter

    Joined:
    Apr 12, 2010
    Messages:
    4
    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!!
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/916346

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice