Solved

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

Posted on 2001-06-05
13
188 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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