I have several thousand files with the following name format:
Doe, Jane 2006-02-25
I wish to rename all the files stripping the date and setting the file created date to the date in the name. For the example above:
File name: Doe, Jane Date created 02-25-2006
Here is a piece of VB script I wrote but I am having problems with the lines that change the file name and create date:
Dim FileName As String, NewFileDate As String, NewFileName As String
Dim pos As Integer
ChDir "\Temp1"
FileName = Dir("\temp1\*.*")
While FileName <> ""
pos = InStrRev(FileName, " ")
NewFileName = Left(FileName, pos - 1)
Trim NewFileName
NewFileDate = Mid(FileName, pos + 1)
NewFileDate = Left(NewFileDate, Len(NewFileDate) - 4)
Debug.Print FileName, "]" & NewFileName & "[", "]" & NewFileDate & "["
'***** Shell "ren """ & FileName & """ """ & NewFileName & "" ***** PROBLEM HERE
'***** Shell "Touch """ & NewFileName & """ /d:" & NewFileDate ***** PROBLEM HERE
FileName = Dir
Wend
Can someone either help me with my code or provide a different approach?
Thanks!
Shell "ren " & chr(34) & FileName & chr(34) & " " & chr(34) & NewFileName & chr(34)
I wouldn't think that touch would cause a problem though, unless it's not in your path...have you tried pointing to the container folder for touch?