Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VB script

Status
Not open for further replies.

calvarado536

Technical User
Aug 14, 2014
10
US
I already have a script that creates a new folder in a directory every day with the date from the day before. (have the script running with task scheduler daily). Spreadsheets are saved to this directory as well and they need to be put into the correct dates folder. I need help writing a VBScript that will take all the .xlsx files in the directory and put them into the folder with yesterdays date. This is the script that I have so far, I need help with having the script figure out the date for the go to folder.

Option Explicit
Dim fso


Set fso = CreateObject("Scripting.FileSystemObject")

fso.MoveFile "C:\Payment Report\*.xlsx", "C:\PART THAT I NEED HELP WITH"
 
I already have a script that creates a new folder in a directory every day with the date from the day before
So, where is your problem ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I need help writing a VBScript that will take all the .xlsx files in the directory and put them into the folder with yesterdays date.

essentially, I need the .xslx files that are put into the directory to be moved into the new folder that is created by my first script (the one that I mentioned in my first sentence).
 
I think I should add that the script needs to be run every day and that the name of the folder is different every day since it is yesterdays date.
 
Well, what is the code of your script creating the folder ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
option explicit

Dim objFSO, objFolder, strDirectory
Dim fso, folder, dt

strDirectory = "C:\Payment Report\folder"

Set objFSO = CreateObject("Scripting.FileSystemObject")


Set objFolder = objFSO.CreateFolder(strDirectory)

Set fso = CreateObject("Scripting.FileSystemObject")

Set folder = fso.GetFolder("C:\Payment Report\folder")

dt = DateAdd("d", -1, Date)

folder.Name = Month(dt) & "." & Day(dt) & "." & Year(dt)



Set folder = Nothing

Set fso = Nothing
 
never mind I figured it out after playing with it. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top