Solved

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

Posted on 2001-06-05
13
190 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:ez_eddie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 1

Expert Comment

by:svaik
ID: 6156541
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6156562
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
 

Expert Comment

by:siqubal
ID: 6156564
uSE THE FILE SYSTEM OBJECTS
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:svaik
ID: 6156580
jrspano : On EE we never propose an answer, its a non-write rule!
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6156582
Simplest VB Method is

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

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6156586
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
 
LVL 3

Expert Comment

by:jrspano
ID: 6156621
jrspano : On EE we never propose an answer, its a non-write rule!

I didn't propose an answer siqubal did.
0
 
LVL 1

Expert Comment

by:svaik
ID: 6156635
sorry :(
siqubal : On EE we never propose an answer, its a non-write rule!
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6156694
no problem. I agree, especially when the proposed answer is given by 2 previous comments and doesn't give any real info.
0
 
LVL 5

Expert Comment

by:AndrewDev
ID: 6156839
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
 
LVL 2

Expert Comment

by:Microsoft
ID: 6156904
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6157105
Name "c:\xxxxxx.txt ", "xx" & format$(now,"mm-yy")  & ".txt"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6157106
Name "c:\xxxxxx.txt ", "c:\newfold\xx" & format$(now,"mm-yy")  & ".txt"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question