-
Jan 27th, 2000, 09:28 AM
#1
Thread Starter
Lively Member
I have a whole directory of that my program needs to rename.
This is a sample of what the files look like, they all have different names, but I need to retain the first 8 characters an the last 3 (extension).
1573-001111.doc
1822-309369.doc
etc...
I have seen somewhere on how to rename files by stripping out unnessary text, I don't remember where or what to do.
Thanks,
Mike
-
Jan 27th, 2000, 10:58 AM
#2
Use the Name.. As.. Statement, ie.
Code:
Dim sDir As String
sDir = Dir("C:\Files\*.doc")
While Len(sDir)
If (GetAttr("C:\Files\" & sDir) And vbDirectory) <> vbDirectory Then
Name "C:\Files\" & sDir As "C:\Files\" & Left$(sDir, 8) & Right$(sDir, 4)
End If
sDir = Dir
Wend
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
-
Jan 27th, 2000, 11:18 AM
#3
Thread Starter
Lively Member
Thanks,
It worked perfectly
Mike
-
Jan 27th, 2000, 02:11 PM
#4
Thread Starter
Lively Member
Ok, I ran into a snag, not all the files follow the same form as what I thought.
How do I use the middle command to strip out 7 characters in the middle of the file names. The only thing consistant is that the beginning of the characters to remove are counted from the right.
ex: 1573-0011*******.doc
what I ran into is that all the files were not named correctly.
Any help would be greatly appreciated,
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|