I use a lot the FOR command in the TCC command line to process sets of files (to check on them, move them around, etc.). A quickly typed command does well and good... until a filename containing spaces shows up, which produces wonky results. For example:
Sometimes, it's an unexpected result (as above), sometimes is a "file not found" error per offending file, et cetera. Yes, it's a simple matter of placing quotes around each occurence of the variable name ("%A", in the example above) to avoid the problem, and yet... the user can forget to add them.
I think it'd be quite convenient to add a /Q option to the FOR command, where its presence indicates that each occurrence of the variable is to be enclosed in quotes. In my example, the command would internally become:
I don't recall ever using the FOR command directly in a command line (cmd or tcc). In a batch file, yes, but not in the command line. For MOVE or DEL, I generally use the "/p" option, and file names with spaces are properly handled by TCC.
But why the /P? It handles it without /P properly too.
Of course if you really need a prompt to check it before, then it's clear. But for automated processing you don't need it. Additionally if you have really many files which give many findings and you have to answer the prompt for each ...
I am aware of what the /P option does. I like to use it just to be on the safe side. My point was that I don't need to use a FOR loop on the command line to implement a MOVE or DEL.
There are probably some circumstances under which the FOR loop might be preferable, but offhand I can't think of one.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.