Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2001-06-05
13
Medium Priority
?
198 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
Technology Partners: 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 300 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

704 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