In the source folder there are 3 files:
a.csvb.csva.csv_backup
I would expect *.csv to copy a.csv and b.csv only, but it copies a.csv_backup as well.
Code:
Dim oFso As New Scripting.FileSystemObject
oFso.CopyFile "c:\temp\*.csv" "d:\temp\"
In the source folder there are 3 files:
a.csv b.csv a.csv_backupI would expect *.csv to copy a.csv and b.csv only, but it copies a.csv_backup as well.
Code:
Dim oFso As New Scripting.FileSystemObject
oFso.CopyFile "c:\temp\*.csv" "d:\temp\"
You're running into the fact that each file has a "short name" (the old DOS 8.3 standard) for compatibility with really old software (some of which is still kicking around). Your file a.csv_backup is also known by another name (probably something like a~1.csv though it could be about anything) which only uses the first three letters of the extension. You can run dir /x to see the short names alongside each long name.
Further reading:
In terms of a solution, you either need your backup extension to not share the first three characters of what you're searching for (so use something like .backup_csv instead), or you need to disable short names on your system (which can break old applications).