Home » Questions » Computers [ Ask a new question ]

How can I get the "dir" and "copy" commands to operate on "*.xyz" but not "*.xyz~"?

How can I get the "dir" and "copy" commands to operate on "*.xyz" but not "*.xyz~"?

When I use copy *.txt somefolder\ the system seems to copy all *.txt~ files too, which is not what I want. A similar same effect can be seen with dir:

Asked by: Guest | Views: 513
Total answers/comments: 4
Guest [Entry]

My solution was to execute del *.xyz~ prior to my copy *.xyz. Not brilliant, but it works.
Guest [Entry]

"I'm not sure how to stop dir/copy from matching only *.txt but I can explain why *.txt returns what it does; it matches the short file name which ends with .txt for all the files, do a dir /x *.txt to see this. This problem occurs for every set of extensions that start with the same first three characters (e.g. *.htm will match htm, html, and even htmlasdfasdf).
Also most every Windows application will act this way because the API the OS provides to search for files FindFirstFile matches the long file names and short files names. To quote:

The search includes the long and short file names.

You'll have to do some sort of custom filtering as Johannes Rössel answer suggested."
Guest [Entry]

"you could try:
copy ""*.txt"""
Dcibtm [Entry]

order lipitor without prescription <a href="https://lipiws.top/">buy lipitor 20mg pill</a> atorvastatin over the counter