Loop, Files, *.csv match 1.csv and 1.csvabc Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tuzi
Posts: 223
Joined: 27 Apr 2016, 23:40

Loop, Files, *.csv match 1.csv and 1.csvabc

Post by tuzi » 19 Jul 2020, 05:44

[Moderator's note: Topic moved from Bug Reports.]

Code: Select all

Loop, Files, *.csv
	MsgBox, %A_LoopFileName%
if i have 2 files 1.csv and 1.csvabc
i think *.csv means match 1.csv not 1.csvabc
but they can both match
is a bug?

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Loop, Files, *.csv match 1.csv and 1.csvabc

Post by swagfag » 19 Jul 2020, 06:30

Code: Select all

#Requires AutoHotkey v1.1.33.02

for each, ext in ["csv", "csvabc"]
	FileOpen("1." ext, "w")

Loop Files, *.csv
	MsgBox % A_LoopFileName
cant reproduce, only 1 msgbox is shown - 1.csv

TAC109
Posts: 1112
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Loop, Files, *.csv match 1.csv and 1.csvabc  Topic is solved

Post by TAC109 » 19 Jul 2020, 17:48

This Windows 'effect' as described by the OP depends on whether 8dot3names is switched on or not for the disk containing the relevant files. If 8dot3names is on, matching is done on both the long name and the short name.

You can confirm this from an administrator DOS prompt by typing fsutil 8dot3name query D: (where D: is your drive letter) and pressing enter. You’ll probably find that 8dot3names are enabled on the C drive and disabled on other drives.

You can check the short names in a folder from a command prompt by typing dir /x <folder name> and pressing enter. Note that there will be no short name created if the long name fits the short name model.

In other words, this is not a bug in AutoHotkey.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe

tuzi
Posts: 223
Joined: 27 Apr 2016, 23:40

Re: Loop, Files, *.csv match 1.csv and 1.csvabc

Post by tuzi » 22 Jul 2020, 05:23

@swagfag
@TAC109
thank you gays. TAC109 is right.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation
Edit registry, set this value to 1, disable 8dot3Name, and reboot windows, it's ok now! :thumbup:

lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: Loop, Files, *.csv match 1.csv and 1.csvabc

Post by lexikos » 25 Jul 2020, 21:57

Are you sure?
Changing this value does not change the file, but it does change the way that NTFS displays and manages the file. Also, files are named according to whatever rule is specified by this entry at the time of their creation; changing this entry does not alter the names of existing files.
Source: NtfsDisable8dot3NameCreation: Core Services | Microsoft Docs
If you didn't recreate the files, they should still have 8dot3 names, so *.csv would still match the previously existing .csvabc files.

You can change the setting without rebooting by running fsutil.exe behavior set disable8dot3 1 (or 0).
TAC109 wrote:This Windows 'effect' as described by the OP depends on whether 8dot3names is switched on or not for the disk containing the relevant files.
To be precise, it depends only on whether short names exist for the relevant files. The current setting of 8dot3names affects file creation, not the matching of file patterns.

tuzi
Posts: 223
Joined: 27 Apr 2016, 23:40

Re: Loop, Files, *.csv match 1.csv and 1.csvabc

Post by tuzi » 26 Jul 2020, 21:49

@lexikos
you are right.
i test it use ram disk. so when i reboot, just edit registry is ok.
if use real disk, you are right!thanks!

Post Reply

Return to “Ask for Help (v1)”