// Edit
I really appreciate the comment made by the verdy_p. it's not only relevant but also incredibly enriching. It adds great value to the discussion, and that's why I've decided to include it in the edit. Thanks for sharing such thoughtful input!
Querying the registry directly at specific path for getting the NTFS behavior is not recommended.
You should use FSUTIL behavior query disable8dot3 [volume]
Note that there's a system-wide default setting (the one that the registry query above may return), which can be overriden on specific volumes (in addition FSUTIL works also for non-NTFS filesystems, such as FAT32, ExFAT, ReFS, and possibly even HPFS, NFS, Ext4 or other network filesystems, if the relevant filesystem drivers are installed and if they support such Windows behavior option). – verdy_p
Note Using the FSUTIL
command, execution requires admin credentials.
//
You need one for loop
to avoid some 3rd file with additional characters after ".tmp
" to be deleted too...
for /t tokens^=* %i in ('where .:*.tmp')do echo\ del "%~i"
The where command will return only files .end
with .tmp
(only)...
You can also try /R
ecursive:
for /t tokens^=* %i in ('where/r "D:\MyProject\Folder" *.tmp')do echo\ del "%~i"
I can't explain the reason for this event that happened to you, but it happens to me too...
Now I know... @phuclv explained in his answer ... plz, consider his answer
> reg query "HKLM\System\CurrentControlSet\Control\FileSystem" /v "NtfsDisable8dot3NameCreation"
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem
NtfsDisable8dot3NameCreation REG_DWORD 0x0


- Using
For /f
with where
to keep files *.tmp*

I also don't know how to explain why this event doesn't happen with @spikey_richie...
del *.tmp
should only delete files with the.tmp
file exttension that exist within the directory the command was issued in.file.exe *.txt
passes the raw*.txt
string to the file.exe. Windows also doesn't split arguments and the program must parse its own command line to get the list of tokens. In reality the C runtime does that for youproject.tmpl
has the "8.3" namePROJEC~1.TMP
. The Windows API provides a function (SetFileShortName()
) that allows changing (renaming) the "8.3" file name of a file without changing the "long" name. So your file might still be namedproject.tmpl
but the "8.3" name may beproject.tpl
instead ofprojec~1.tmp
. Unfortunately, I didn't find out if there is a "ready" command line command or if you'd have to write a short C/C++ program to do this...