The FileSystemObject
command CopyFile
will take any file and make a copy of it, but it leaves the modified date intact. Is there a way to open an existing image (JPG, PNG, etc.) file and "write" it to the directory instead (two-step process?) that would cause the modified date to change? I know FileSystemObject
can do this with text files, but not sure if there is a way to do it with a JPG or PNG.
You can do it this way:
FileSystemObject.CopyFile
"Touch" the copied file with the function provided in this SO question:
Sub touch(strDir, strFileName, DateTime)
Dim objShell, objFolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strDir)
objFolder.Items.Item(strFileName).ModifyDate = DateTime
End Sub
... Pass the current date to touch()
:
touch strDir, strFileName, Now