Adding a command to the Button Bar

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
unkis17
Junior Member
Junior Member
Posts: 80
Joined: 2006-07-31, 20:49 UTC
Location: Chicago, IL

Adding a command to the Button Bar

Post by *unkis17 »

I find myself using:

dir /w /b >>c:\lister.txt

all too frequently for lists of all kinds.

1. I tried entering into the button bar with "dir" as the command and it keeps telling me "File Not Found." What am I doing wrong?

OR

Does TC do this already and I am not aware of it (or something close to it)?
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

dir is a command inside command console.
You have to add %comspec% /c in front of dir.

%comspec% is a system variable that points to the standard command processor, cmd.exe on 2000/XP, command.com on WinDOSes.

Icfu
This account is for sale
User avatar
Sam_Zen
Power Member
Power Member
Posts: 700
Joined: 2005-02-08, 22:59 UTC
Location: NL
Contact:

Post by *Sam_Zen »

Thanks for bringing this up .. I have pipelined many times dir-content to a txt-file, and it's nice to know the conventions to make a button for it.

Some things remain though. This button would produce every time a file named 'lister.txt'. So, unless you take precautions, the previous 'lister.txt' will be overwritten.
Another option could be : using the format of a batch-file. A batch usually is filled with a sequence of commands, but it functions too with a one-liner.
Since a batch-file (.bat) is considered as being an executable, it's more easy to connect a button to it.
If the batch-file is located in one of the system-paths, then it can be called from any directory.
The problem of overwriting the previous output is not yet solved with this.
But a batch-file knows at least 9 variables, with a '%' prefix. These variables can be declared after the command.
Example : "listdir.bat" (ascii-format) contains the line :

dir /w /b >>c:\%1.txt

If you want such a file of the directory "photo", enter that place. You could then give the command :

listdir photo

and the file "photo.txt" is written.
How this could be implemented in a button, I don't know.
0.618033988
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

This button would produce every time a file named 'lister.txt'. So, unless you take precautions, the previous 'lister.txt' will be overwritten.
Why should it be overwritten? >> means attach.
listdir photo

and the file "photo.txt" is written.
How this could be implemented in a button, I don't know.

Code: Select all

command: cmd.exe /c /v:on
parameter: set /p filename=Enter the target filename (.txt will be added automatically):&&dir /w /b>"!temp!\!filename!.txt"&&notepad.exe "!temp!\!filename!.txt"
Icfu
This account is for sale
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1052
Joined: 2004-07-29, 11:00 UTC

Post by *ZoSTeR »

I use another variant:

Code: Select all

Command:
%comspec% /c dir /b >

Parameter:
?filelist.txt
This will prompt for the filename with "filelist.txt" as default.
Post Reply