• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 758
  • Last Modified:

Need a vbs copy script

I am looking for a VBS script that will copy a file(s) with the previous days date from one location to another.
0
ohmErnie
Asked:
ohmErnie
1 Solution
 
chandru_solCommented:
0
 
RobSampsonCommented:
Hi, does this file have a specific name, or are you searching through a folder?  Or does the file name include yesterday's date in the file name? Or are you wanting to check the date last modified?  Please provide more info on what you want to copy from where....

Regards,

Rob.
0
 
ghostdog74Commented:

N=Now
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder="c:\source_dir"
strNewDest = "c:\new_dest"
Set objFolder = objFSO.GetFolder(strFolder)
For Each strFiles In objFolder.Files
      If DateDiff("d",N, strFiles.DateLastModified) = -1 Then            
            objFSO.MoveFile strFiles , strNewDest & "\" & strFiles.Name
      End If
Next
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ohmErnieAuthor Commented:
ghostdog74,

This script only seems to copy 1 of the files with a date Now - 1.  How do I get it to copy more than 1 file that has a modified date of Now - 1?
0
 
RobSampsonCommented:
ghostdog74's code should copy more than one file.....in fact, it should copy every file in the folder from strFolder that has a difference in date of -1.  Are you sure you have more than 1 file that has a last modified date of yesterday?

Regards,

Rob.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now