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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File information 1

Status
Not open for further replies.

omegabeta

Programmer
Aug 20, 2003
148
RO

I want to copy a file from \\comp1\share into \\comp1\share\01 or 02... depending on the name of file.
The name of file is like file2901.txt, file0202.txt.

So I know the path \\comp1\share where I have a file.
How can I get the name of this file to extract only the month and then copy it in the corresponding folder ?

Thank in advance
 
Get a reference to your source folder,,,something like

Set objSourceFld = FSO.GetFolder("\\comp1\share")

strMonth = Month(Now)

'Then something like
For Each aFile In objSourceFld.Files
If Right(aFile.Name, 6) = strMonth & ".txt" Then
'we need to copy file
FSO.CopyFile aFile, "\\comp2\share\" & strMonth
End If
Next


the above is pretty crude but it should give you something to start on, the whole Right(aFile.Name, 6...will need addressing

regards
richard
 
Hey..

You have to remember that leading zero in the month number :)

according to mrmovie:
---

strMonth = Month(Now)

'add these lines..

if int(strMonth) < 10 then
strMonth = &quot;0&quot; & strMonth
end if
---

that should do it..

Jay

 
or
right(100+month(now()),2)


if it is to be it's up to me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top