3

In the source folder there are 3 files:

  • a.csv
  • b.csv
  • a.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\"
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
coder
  • 4,121
  • 14
  • 53
  • 88

1 Answers1

4

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).