Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename multilple files and copy

Status
Not open for further replies.

GRonken

Programmer
Oct 30, 2003
26
0
0
US
I would like to get a list of the files in a directory and rename them. I can count the number of files, I have done it with a single file, but now I have 2 files and need to rename (append a date stamp)to them than copy them to another directory.
 
Try a keyword search in this forum for fso move and come back with what you have so far.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
receiving an error .. can't find file

Set FileObject = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = FileObject.GetFolder("C:\DATA\FTP\ARI\")
Set TargetFolder = FileObject.GetFolder("C:\DATA\FTP\ARI\ARCHIVE")
Set FileCollection = SourceFolder.Files

'Get the list of files
For Each File in FileCollection
File.name = Mid(File.name, 1) + "datestamp"
Next

-- the above renames them just fine .. BUT move or copy them is different ..

For Each File in FileCollection
FileObject.MoveFile SourceFolder & File.name, TargetFolder
Next
 
Try with this:
Set TargetFolder = FileObject.GetFolder("C:\DATA\FTP\ARI\ARCHIVE\")

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
I did this and it worked .. now to format the datestamp ... using replace .. should be no problems ..

FileObject.MoveFile "C:\DATA\FTP\ARI\*.*", "C:\DATA\FTP\ARI\ARCHIVE"

Thanks for the help .... and more importantly the direction to look ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top