Normal Topic JPSoft Take Command utilities (Read 1648 times)
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
JPSoft Take Command utilities
May 8th, 2011 at 3:54am
Print Post Print Post  
As I have mentioned before, JPSoft has a free version of their replacement command shell, TCCLE. [url]http://jpsoft.com/tccle_cmd_replacement.html[/url] Although the free version does not include things like user-defined functions, it is still very powerful.  It is particularly useful for administrative tasks.

Here is a "tree-walker" utility I wrote several years ago that I find very useful.  From the command line it lets you go up or down directories by picking from a menu.  The tree-walker itself is sel-dir.btm and that is shortened by creating an alias "sd".  I'll put several aliases in the next post.

[hr]

:  sel-dir.btm
:  by Joseph "Rick" Reinckens
:  sel-dir (Select Directory) is a "tree-walker"
:  program that lets you go up or down one directory
:  level using a "Point and Shoot" menu. The list of
:  files Shown can be either by name or extension.
:
:  Note: An Inkey statement limits selectable drives


@echo off

iff "%1"=="?" .OR. "%1"=="h" .OR. "%1"=="H" then
  echo Point-n-Shoot menu to go to new directory
  wait 30
  quit
endiff

:DIR_LOOP
set titleprompt=Directory: %_cwd
cls
*select /A:D/O:N cd (*.*)

:  echos Directory^s^s
: set titleprompt=Directory: %_cwd
cd
echo.
echo  ^<Enter^>=Repeat  ^<Esc^>=Quit
echos  ^<S^>how ^<D^>rive  ^<E^>xt^s
inkey /K"[Enter][Esc]sSdDeE?" %%qr

:  <Enter>
if %qr%==13 .OR. "%qr%"=="@28" goto DIR_LOOP

set qr=%@upper[%qr%]

set qr=%@ascii[%qr%]

:  <Esc>
if %qr%==27 goto DONE
                 
:  Change <D>rive
iff %qr%==68 then
  :  Overwrites the 'd' selection
  screen 3 17
  :  
  echos ^sDrive:^s

  :  Set allowable drives
  inkey /K"acdefghimnpsw" %%seldir

  %seldir%:
  set seldir=
  goto DIR_LOOP
endiff

:  <E>xt Show files by extension
iff %qr%==69 then
  *dir /p /o:e /j
  echo.
  pause
  goto DIR_LOOP
endiff

:  <S>how files: Name.Ext
iff %qr%==83 then
  *dir /p
  echo.
  pause
  goto DIR_LOOP
endiff
                 
iff "%qr%"=="?" .OR. "%1"=="h" .OR. "%1"=="H" then
  echo Point-n-Shoot menu to go to new directory
  wait 30
goto DIR_LOOP

:DONE
set qr=
set titleprompt=

[hr]

« Last Edit: May 8th, 2011 at 4:54am by Rick_R »  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: JPSoft Take Command utilities
Reply #1 - May 8th, 2011 at 4:53am
Print Post Print Post  
Below is a TCCLE batch file that defines several useful aliases.  Once this is run (it should be included in tcstart.bat in C:\Program Files\JPSoft\TCxx) it defines the aliases until that TCCLE session ends.  The utilities are described below.


: Create a directory join to the current directory in the current directory
alias CLONEDIR=`mklnk "%_cwd" %@quote[-%@name[%_cwp]]`


: Create a hard link to the specified file in the same directory with a minus appended
alias CLONEDOC=`mklnk %@quote[%@lfn[%1]] %@quote[%@lfn[%1]-]`

:  Do math
alias MATH=`Echo %@eval[%&]`

:  Select drive, then directory, then show
:  You need to install the sel-dir.btm file in the appropriate folder
alias SD=`"c:\Program Files\JPSoft\sel-dir"`

: Create a temp drive
alias TDRv=`subst %1: "%_cwd" & %1:`



CLONEDIR is used where you have multiple programs that create the same type of files.  For instance, Paint Shop Pro, Adobe Photoshop Elements, and many other programs install stock images such as flowers, animals, buildings, etc.  Usually each program installs those in C:\Program Files\ProgramName\Images or something similar, and they can take up hundreds of megabytes.

I'll use two programs as examples: Program A installs \Program A\Graphics and Program B installs \Program B\Images.  Each expects to find its files in that spot.

With CloneDir, you install Program A and then Program B.  Go back to \Program A\Graphics and in TCCLE type "CloneDir".  In \Program A\Graphics it will create a directory join name -Graphics.

Next, go to \Program B\ rename the \Images folder, e.g., \Images-orig.

Then cut, paste and rename the -Graphics join in \Program B\

In other words, the directory structure will now look like this, all descended from C:\Program Files\

\Program B\Images
\Program B\Images-orig

When you list \Program B\Images, you will see the same content as \Program A\Graphics

Now move everything from \Images-orig into the \Program B\Images folder.

The result will be that each program will see the files it expects to see but each will have access to all the files from both programs--without having to duplicate the files.

CAUTION! -- Once you have run CloneDir, immediately move the directory join!  What CloneDir does is create a join in the folder it is pointing to!  In other words, it creates an endless loop.

A directory join and a junction are similar but not identical.  Functionally they are like Windows shortcuts.  A difference is that a shortcut literally points somewhere else.  If the target file or folder is moved or renamed the shortcut "breaks".  A directory join or junction is a second pointer to the actual physical file.  Hence, even if the original file/folder is "deleted", the actual file/folder will continue to exist because it has two names.  Many programs will not use a shortcut, the actual folder name must be used.  With a directory join/junction, the programs see the actual folder, not a shortcut.

In addition to having all the graphics programs use the same folders, I also use it for Favorites.  I have a folder C:\Most Used which is my actual favorites folder.  With other programs, I delete their Favorites folder and use a directory join to C:\Most Used and I rename the join to whatever that program expects.



CLONEDOC is similar to CloneDir except that it creates a hard link to a file instead of a directory join/junction.  This has several uses:

1) You may need access to a single file from multiple locations, e.g., each user accesses C:\Reference Data\Phone Book.2009.txt and that file needs to remain current.  If files are moved from time to time (e.g., Active moved to Closed) and reorganized, shortcuts will break but a hard link won't.

2) A clone can be used for security.  The physical file is not deleted until every hard link is deleted.  (Every file has at least one hard link--the name it is currently saved under.)

3) For convenience you may need to refer to the same file by multiple names (e.g., Hamilton Report.2Q2008.pdf and Undisbursed Funds.2Q2008.pdf).  (This is particularly useful in a highly political environment where some high-up jerk refuses to follow naming conventions and gets mad if subordinates rename files.  Just create a clone link somewhere else that follows the naming convention.  Even if the user moves or renames the file the clone link will still work.)



MATH does quick command-line math.  Just type MATH and whatever you want to calculate and it will show the result.



SD calls the sel-dir.btm tree-walker utility.



TDRV creates a temporary drive at the current location using the DOS SUBSTitute command.  This is particularly useful when you are 8 levels down and need to move or copy things to someplace else 6 levels down.  You go to your source directory (... use SD ...) and type TDRV G, go to your target directory and type TDRV H.  Then you can copy/move from Drive G: to Drive H: instead of a long path.

The temporary drives will last until reboot or you can use SUBST /D Driveletter: from a command prompt.
  
Back to top
 
IP Logged