How to filecopy and rename file with current month and day....

How to copy a txt file to another folder and rename it to include the current month and day of the system.

Ex. folder A file= xxxxxx.txt copy this to folder B as
             file= xx0605.txt

thanks in advance.
ez_eddieAsked:
Who is Participating?
 
TimCotteeHead of Software ServicesCommented:
Simplest VB Method is

strOldFile = "c:\MyFolders\A\xxxxxx.txt"
strNewFile = "c:\MyFolders\B\xx" & Format(Now,"MMDD") & ".txt"
Name strOldFile strNewFile

0
 
jrspanoCommented:
use file system object

  Dim fso As FileSystemObject
 
  Set fso = New FileSystemObject
  fso.CopyFile Source, Destination
  Set fso = Nothing

set a reference to windows scripting
your destination can be any file name so you can change the file name here
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
siqubalCommented:
uSE THE FILE SYSTEM OBJECTS
0
 
svaikCommented:
jrspano : On EE we never propose an answer, its a non-write rule!
0
 
TimCotteeHead of Software ServicesCommented:
This means that you don't have to add the extra overhead required for the Microsoft Scripting Runtime (which may or may not be installed) and dependent on where you install your application(s) may not be permitted by certain system administrators.
0
 
jrspanoCommented:
jrspano : On EE we never propose an answer, its a non-write rule!

I didn't propose an answer siqubal did.
0
 
svaikCommented:
sorry :(
siqubal : On EE we never propose an answer, its a non-write rule!
0
 
jrspanoCommented:
no problem. I agree, especially when the proposed answer is given by 2 previous comments and doesn't give any real info.
0
 
AndrewDevCommented:
Take a look at these you might find them useful

Using Shell API
http://www.freevbcode.com/ShowCode.Asp?ID=499

Using Win32API
http://www.freevbcode.com/ShowCode.Asp?ID=498

Using File System Object
http://www.freevbcode.com/ShowCode.Asp?ID=2383

Good Luck
Andrew
0
 
MicrosoftCommented:
why not try this :-

filecopy "c:\test1\test.txt","c:\test2\newfile.txt"

or

filecopy c:\test1\test.txt","c:\test2\test.txt"
name "c:\test2\test.txt" as "c:\test2\newfile.txt"

im at work at the moment but I think that should rename an existing file to a new file with the current pc date.


Many Thanlks


Andy
0
 
Richie_SimonettiIT OperationsCommented:
Name "c:\xxxxxx.txt ", "xx" & format$(now,"mm-yy")  & ".txt"
0
 
Richie_SimonettiIT OperationsCommented:
Name "c:\xxxxxx.txt ", "c:\newfold\xx" & format$(now,"mm-yy")  & ".txt"
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.

All Courses

From novice to tech pro — start learning today.