Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Wierd problem wih "for" command...

May
855
0
I'm not sure I'm posting this in the right place, but I have a weird problem with the following command:

Code:
For /R G:\ /D %D in (*) Do (Echo %@Right[17,%@Repeat[ ,17]%@Comma[%@FileSize["%D"]]] %@Right[17,%@Repeat[ ,17]%@Comma[%@FileSize[/S "%D"]]] %D) | Sort /+1 >>Z:\G-Drive.txt
The problem? While it mostly works I get a series of messages (129 of them to be exact) that are similar to the following.

TCC: Unknown command "T-SBC-Yahoo!"
TCC: Unknown command "T-Yahoo!"
TCC: Unknown command "Some"
I even get a message stating:

Usage : RENAME [/A:[[-][+]rhsdaecjot] /B /E /I"text" /MD /N[enst] /O:[-]adegnrstu /P /Q /S /T]
old_name... new_name
And, as you can see, there is no "rename" command in the above sequence.

I'll admit that this more academic than anything else, but I would really like to know what's going on here and if there is some way for me to avoid these messages.

TCC 12.01.44 Windows 7 [Version 6.1.7600]
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Sunday, 2011. March 6. 19:12
Subject: [Support-t-2654] Wierd problem wih "for" command...

| I'm not sure I'm posting this in the right place, but I have a weird
| problem with the following command:
|
|
| Code:
| For /R G:\ /D %D in (*) Do (Echo %@Right[17,%@Repeat[
| ,17]%@Comma[%@FileSize["%D"]]] %@Right[17,%@Repeat[
| ,17]%@Comma[%@FileSize[/S "%D"]]] %D) | Sort /+1 >>Z:\G-Drive.txt

| The problem? While it mostly works I get a series of messages (129 of
| them to be exact) that are similar to the following.
...

I suspect you have filenames (or directory names) on your G: drive which include your command separator ("compound") character [by default it is the ampersand &], thus the rest of the file name is considered to be a command but it is not a legal command. What could be worse than just the error message if the command is legal and its execution undesirably alters your file system (deletes or modifies files). You need to quote it to eliminate this possibility everywhere.

BTW, the @FILESIZE command can return a size with embedded commas: %@filesize["%d",bc] - you do not need to use the @comma function. If you want the filesize to be right justified in a 17-column field, the simplest way is %@format[17,%@filesize["%d",bc]]. You could just define a function:
function fs17=`%@format[17,%@filesize[%1,bc]]`
and use it to simplify your command.
--
Steve
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Sunday, 2011. March 6. 19:12
Subject: [Support-t-2654] Wierd problem wih "for" command...

| I'm not sure I'm posting this in the right place, but I have a weird
| problem with the following command:
|
|
| Code:
| For /R G:\ /D %D in (*) Do (Echo %@Right[17,%@Repeat[
| ,17]%@Comma[%@FileSize["%D"]]] %@Right[17,%@Repeat[
| ,17]%@Comma[%@FileSize[/S "%D"]]] %D) | Sort /+1 >>Z:\G-Drive.txt

| The problem? While it mostly works I get a series of messages (129 of
| them to be exact) that are similar to the following.
...

I suspect you have filenames (or directory names) on your G: drive which include your command separator ("compound") character [by default it is the ampersand &], thus the rest of the file name is considered to be a command but it is not a legal command. What could be worse than just the error message if the command is legal and its execution undesirably alters your file system (deletes or modifies files). You need to quote it to eliminate this possibility everywhere.

BTW, the @FILESIZE command can return a size with embedded commas: %@filesize["%d",bc] - you do not need to use the @comma function. If you want the filesize to be right justified in a 17-column field, the simplest way is %@format[17,%@filesize["%d",bc]]. You could just define a function:
function fs17=`%@format[17,%@filesize[%1,bc]]`
and use it to simplify your command.
--
Steve

Thank you, Steve, you are, of course, correct. I am careful to NOT make file and directory names that way myself, but files I import from outside sources (the case here) sometimes use those characters and I don't notice.

And thank you again, Steve, I didn't know some of the above and I'll (try to remember to) do it that way in the future. But it really doesn't matter that much because I didn't find it particularly difficult (either to compose or type) to do it the way I did do it.
 

Similar threads

Back
Top