Solved Script for File Move

August 12, 2011 at 09:08:51
Specs: Windows XP
New to scripting ... need a script or method to move files from one server/folder location to another, based on date. I manually moved most of the folders/files, but want to automate this. So, on September 1, want to automatically move files in folder 201105 from one location to another.

See More: Script for File Move

Report •

August 12, 2011 at 09:42:12
New to scripting
Step 1) Be as specific as you can be. "one location" (that apparently contains a directory called "201105"? All the time? Or just some times? How does the date factor into this?) and "another location" might be a bit too vague for someone to build a script off of.

Step 2) Let us know what you're trying to do. Is this a backup script? Some special operation done on arbitrary dates that just happen to include September 1?

Step 3) When writing or requesting a script, write it as if you're trying to describe the intimate details of the process to someone who has no idea the process exists. Because we don't, and neither does your computer.

How To Ask Questions The Smart Way

Report •

August 12, 2011 at 10:10:47
Ok, thank you.

Text files are written to a network share on a daily basis. Our finance department creates monthly folders (i.e., 201101) and moves the daily files into the folder. They need access to the files on their share for 3 prior months, plus the current month (so, this being August, they need May, June, July and August).

I need a procedure to move the old folder from the finance share to a 10-year archive share (same server, different directory). So, on Sept. 1, I would want to "automatically" move the 201105 folder and it's contents. On Oct. 1, I would need to move the 201106 folder and its contents, etc.

Thank you.

Report •

August 17, 2011 at 14:26:03
✔ Best Answer
Few things:
You'll have to modify sourcePath and archivePath to point to the locations.
SourcePath is the folder that holds the 2011* folders.
The script assumes the source folder holds only these 2011* folders, otherwise behavior is undefined.
The script assumes the one running this script has all of the required privileges, obviously.
The script assumes a matching 2011* folder will not be found in the archivePath.
Depending on how you plan on running this, logging might need to be added.


Const sourcePath = "c:\someFolder"
      archivePath = "c:\archiveFolder"

If Right(archivePath, 1) <> "\" Then _
  archivePath = archivePath & "\"
cutoffDate = DateAdd("m", -3, Now)
cutoff = DatePart("yyyy", cutoffDate) & Right("0" & DatePart("m", cutoffDate), 2)

For Each dir In 
  If dir.Name < cutoff Then _
    dir.Move archivePath

How To Ask Questions The Smart Way

Report •

Related Solutions

August 17, 2011 at 14:56:45
thank you.

Report •

Ask Question