LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Renaming Zip files

I didn't get that error when I tried the code. (And the code looked fine to
me.)

But I don't like this portion:

CStr(format(FileDateTime(strFilepath), "ddmmyy")) & ".zip"

I think
CStr(format(Date, "ddmmyy")) & ".zip"
or
just
format(Date, "ddmmyy") & ".zip"

would be what you want.

GEORGIA wrote:

ok i got a sample code from someone on this forum...changed it little
Sub Main()
Dim MyPath As String, MyName As String, strfile
MyPath = GetFolder
If MyPath = "" Then Exit Sub
With Application.FileSearch
.NewSearch
.LookIn = MyPath
.SearchSubFolders = True
.Filename = "*.zip"
.FileType = msoFileTypeAllFiles
If .Execute() 1 Then
For Each strfile In Application.FileSearch.FoundFiles
Call RenameFiles(strfile)
Next
End If
End With
MsgBox "Done...", , ":-)"
End Sub

Function GetFolder() As String
Dim ff As Object
Set ff = CreateObject("Shell.Application"). _
BrowseForFolder(0, "please select folder", 0, "N:\File")
If Not ff Is Nothing Then
GetFolder = ff.Items.Item.Path & "\"
Else
GetFolder = ""
End If
End Function

Sub RenameFiles(ByVal strFilepath As String)


Dim strDate As String, OldName As String, NewName As String
OldName = Dir(strFilepath)
NewName = Left(strFilepath, Len(strFilepath) - Len(OldName)) & _
Left(OldName, Len(OldName) - 4) & _
CStr(format(FileDateTime(strFilepath), "ddmmyy")) & ".zip"
Name strFilepath As NewName

End Sub

however, it is giving me an error message @ Sub RenameFile stating
" Wrong number of arguemtns or invalid property assignment".
What does this mean?

Thank you!

"GEORGIA" wrote:

Hi, I download a zip files from our intranet everyday. It comes over like
this:

FL.ZIP
GA.ZIP
CA.ZIP
NY.ZIP

Is there a way to rename those files and add today's date on with vb code?
so it will rename:
FL 091405.ZIP
GA 091405.ZIP
CA 091405.ZIP
NY 091405.ZIP
??
Thank you!


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Renaming Files Bear Excel Discussion (Misc queries) 2 December 5th 05 09:02 PM
Renaming Files mudraker[_304_] Excel Programming 2 August 13th 04 12:04 AM
Renaming Files: Take 2 Dominique Feteau Excel Programming 4 July 14th 04 04:27 PM
Renaming files Dana Wilson Excel Programming 2 October 29th 03 05:34 PM
Renaming Files Spammastergrand Excel Programming 5 September 19th 03 10:43 PM


All times are GMT +1. The time now is 10:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"