473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

subject: renaming a file w/ wildcards in name

5
hello,
I have this code that I'm trying to use but is not working, so I'm posting on here to see if someone can help me with how to fix the error. What the code is trying to do is to look in the subdirectory
D:\B D client data\H T\NewBusiness\
for a file that will have (a string of numbers) + (.txt) as it's file name and rename that file to HT012507.txt.
There is another file in the same directory named HT.txt that needs to be left alone and not renamed. These are the only two .txt files in the subdirectory.

Visual Basic is giving me the
Run-time error '52':
Bad file name or number
when I try to run the code, and stops on the Name line, so I'm assuming the SourceFile line is the problem.

Can anyone help me with what the syntax of the below code so it will work properly?

thanks in advance,
david

Expand|Select|Wrap|Line Numbers
  1. Dim SourceFile, DestinationFile As String
  2.  
  3.  SourceFile = "D:\B D client data\H T\NewBusiness\[1-9]*.txt"
  4.  DestinationFile = "D:\B D client data\H T\NewBusiness\HT" & Format(Date, "mmddyy") & ".txt"
  5.     Name SourceFile As DestinationFile
  6.  
Jan 25 '07 #1
2 1179
dxpert
3
Hi David,

I think your best bet would be to use the CopyFile method from the FileSystemObject...

http://builder.com.com/5100-6373_14-1050078.html
Jan 26 '07 #2
Killer42
8,435 Expert 8TB
The file that you want to rename - is the name always the same length? If so, you could easily use Dir() function to look for "????????.txt", then rename it once you find the current name. Since each "?" represents a character position, HT.txt would not match that mask.
Jan 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
0
by: simpsoro | last post by:
I am trying to run asp.net pages. The server is accessed by students via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and...
0
by: Ron Simpson | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
0
by: simpsoro | last post by:
I am trying to run asp.net pages. The server is accessed by students via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.