[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

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.
0
ez_eddie
Asked:
ez_eddie
  • 3
  • 3
  • 2
  • +4
1 Solution
 
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
 
siqubalCommented:
uSE THE FILE SYSTEM OBJECTS
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
svaikCommented:
jrspano : On EE we never propose an answer, its a non-write rule!
0
 
TimCotteeCommented:
Simplest VB Method is

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

0
 
TimCotteeCommented:
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

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 3
  • 3
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now