1,050 pts.
 How to move a file and append todays date to it using visual basic
I have a report that produces an .rtf file with the same name daily. I want to move that file to a shared network location and append the date to the file so the old files remain when they are moved, plus the date will make it easier to search. How do i do that using .vbs? Here is an example of what I would like to do, of course this does not work: Dim fso, todaysDate Set fso = CreateObject("Scripting.FileSystemObject") todaysDate = Date() fso.MoveFile "C:report.rtf", "\networksharereport" & Date() & ".rtf"

Software/Hardware used:
win xp pro
ASKED: June 17, 2010  8:45 PM
UPDATED: June 22, 2010  8:17 PM

Answer Wiki:
I found my own answer after some trial and error. Hope it helps somebody else out This is a batch file that takes that text file, or any file really, renames it then moves it to the shared location, then deletes the original file echo on ren c:foldernew.txt new%date:~4,2%%date:~7,2%%date:~10,4%.txt copy "C:foldernew%date:~4,2%%date:~7,2%%date:~10,4%.txt" "\serversharefolder1folder2" echo y | del "c:folder*" ---------- Your original script would have worked with some small modifications: <pre>Dim objFSO, todaysDate, newname todaysDate= date() newname = "\networksharereport" & right(day(todaysDate)+100,2) & right(month(todaysDate)+100,2) & year(todaysDate) & ".rtf" set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.MoveFile "C:report.rtf" , newname</pre>
Last Wiki Answer Submitted:  June 22, 2010  8:17 pm  by  carlosdl   63,580 pts.
All Answer Wiki Contributors:  carlosdl   63,580 pts. , swinehart6803   1,050 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _