-
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
-
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
[email protected]
[email protected]
-
Thanks,
It worked perfectly
Mike
-
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