"Change directory" option for command line

Have a suggestion for "Everything"? Please post it here.
Post Reply
jeb54321
Posts: 2
Joined: Mon Oct 06, 2014 11:19 am

"Change directory" option for command line

Post by jeb54321 » Tue Jun 25, 2019 6:54 pm

I know! I know! Talk about scope creep! But please hear me out...

Back in the old MSDOS days, a guy named Peter Norton (yes, *that* "Norton") developed a set of tools he called the "Norton Utilities".

This was the original SysInternals or Nirsoft. Fantastic, gotta have tools. I think the first defragmenter was included at some point, but I digress and my memory fails.

Without. A. Doubt. the single best tool in my mind was called NCD: "Norton change directory".

Again my memory is foggy, but I believe that similar to Everything Search, it kept a list of folders, and allowed you to enter a command like:

Code: Select all

C:\>NCD jimsfolder
And it would find where "jimsfolder" was, and take you there, even if it was nested deep, as if you had typed:

Code: Select all

CD /D D:\top\level\folder\with\jimsfolder
It was absolute MAGIC! Suddenly deep folder trees were no longer my worst nightmare.

As I sit here using Everything Search command line to find the folder I'm looking for, and then copying and pasting the folder into a CD command, I thought "Wow! What if Everything Search (the "ES"command") could accept ES /D jimsfolder and PUSHD me there"?

I think I might even try to craft a batch file to do something like that, but I couldn't help but share that idea because I've always had a dream of writing such a beast to replace NCD, and always got stuck with how to cache the folder structure of a terabyte hard drive just to change folders.

Thanks for - bar none - the single best utility for Windows ever made!

Jim

(P.S. I read through a bunch of topics but confess I didn't search the entire forum for a possible duplicate)

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Tue Jun 25, 2019 9:02 pm

Take a look at QCD :)

I do have a couple of other versions of it. One that uses a QCD filter in Everything to remove a lot of (for QCD) unnecessary folder from the results and a PowerShell version. And probably a few others too.

If you have any suggestions for it, please let me know! Chances are that they will be implemented ..

EDIT: Took a quick look at the code. It is very noticeable that those were my rookie-days of using Everything.
With today's knowledge (still a rookie), I already see (a lot of!) room for improvement. Update will follow (might take a couple of days).

Offtopic:
I LOVE(d) Norton Utilities. That got me into computers. It was the first program I ever hacked (removing licence) ... using Norton Utilities itself :)
Last edited by NotNull on Thu Jun 27, 2019 7:22 pm, edited 1 time in total.

jeb54321
Posts: 2
Joined: Mon Oct 06, 2014 11:19 am

Re: "Change directory" option for command line

Post by jeb54321 » Wed Jun 26, 2019 2:40 pm

I love reminiscing with strangers! :D

And yup, Norton was the first hint that someday I might be able to do as much on a PC as I used to do on a VAX! I have over 200 .BAT files in my dropbox!

And QCD is PERFECT! Just what I was looking for!

Thank you! Thank you!

Jim

void
Site Admin
Posts: 4847
Joined: Fri Oct 16, 2009 11:31 pm

Re: "Change directory" option for command line

Post by void » Wed Jun 26, 2019 2:50 pm

I had some fun making the following escd.bat file:

Code: Select all

@echo off
setlocal EnableDelayedExpansion
FOR /F "tokens=*" %%i IN ('es.exe folder: -max-results 1 -sort-dm %*') DO (SET var=%%i)
cd /d "%var%"
pushd .
endlocal 
popd
This will change the current directory to the most recently modified folder result matching the specified search passed to escd.bat

therube
Posts: 2308
Joined: Thu Sep 03, 2009 6:48 pm

Re: "Change directory" option for command line

Post by therube » Wed Jun 26, 2019 2:59 pm

(QCD works, but I don't care for it.
Neither NCD nor ACD work. Both attempt, but both fail.
ACD has trouble creating its' .idx.
NCD states, "...Directories too complex".

therube
Posts: 2308
Joined: Thu Sep 03, 2009 6:48 pm

Re: "Change directory" option for command line

Post by therube » Wed Jun 26, 2019 4:52 pm

See if Wselect might help in your endeavor.
Wselect offers a window with a list of items for selection in a batch (BAT/CMD) process. The items are read (line by line) from the given file, which can be either fixed, or generated in the batch process. The file may have any number of lines with anything you want to offer. Special options are provided for menus.
Use ES to find your folders sending its' output to a file.
Open that file with Wselect allowing you to choose the particular directory you want ...

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Thu Jun 27, 2019 7:44 pm

therube wrote:
Wed Jun 26, 2019 4:52 pm
See if Wselect might help in your endeavor.
Don't know if this was addressed at me, but: Thank you! Was looking for something like that for a while.
Way better than my clumsy CMD-array / dictionary table approach ..

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Wed Jul 03, 2019 12:03 am

NotNull wrote:
Tue Jun 25, 2019 9:02 pm
Update will follow (might take a couple of days).
I've written an updated version. More details, code and instructions come tomorrow (it's getting late ..).
But to get an impression /preview:
2019-08-06 17_32_44-Window.png
You do not have the required permissions to view the files attached to this post.
Last edited by NotNull on Tue Aug 06, 2019 3:37 pm, edited 1 time in total.

therube
Posts: 2308
Joined: Thu Sep 03, 2009 6:48 pm

Re: "Change directory" option for command line

Post by therube » Wed Jul 03, 2019 1:52 am

(Heh, oh, when I mentioned QCD, I meant, https://stevemiller.net/qcd/ [didn't even realize that he had a "Win7" version - I tested the '98 version], not realizing that NotNull was using the same name.

And while we're at it, for ACD, I meant, https://www.bttr-software.de/freesoft/dirutil.htm#acd.
WCD, I didn't think to try.)

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Wed Jul 03, 2019 6:51 pm

As you might have noticed from the preview-screenshot that SD (*) has now some extra functions:

Functions
  • Everything folder-search function.
Using EVerything /ES to find a partial foldername to go to. When more than one folder match that pattern, a selection dialog will be shown. Select the folder you wanted (or press ESCAPE) and SD will go to that folder.
Whenever you select a folder that way, it will get a 'like'. The folders with the most 'likes' are shown first in the selection dialog, so the next time that folder will be further up in the list; making it easier to select.

  • SpeedDial function.
When there are certain folders you use very frequently, you can define those as a SpeedDial number.
For example: you go often to "C:\Program Files\Everything". Then make that number 1.
SD 1 will bring you directly to that folder.

Beside numbers, you can also use aliases: if you defined SD_pics=D:\data\photos, SD pics will bring you directly to D:\data\photos.

You can define the SpeedDial entries in the SETTINGS section of the script SpeedDial.ini.
A couple of examples are included to get you going.

SD 0 will show you the currently defined speeddials

  • Directory up function.
With CMD's CD command you can go one directory up with the command CD ... If you want to go 2 levels up, you have to run that command twice.
SD can do that in one step: SD ... will go 2 level up; SD .... 3 levels, etcetera

  • "Back button" function
Just like your browser, SD has a back function. Actually: CMD has, but SD is using it.
You can go to the previous folder with the command SD -
For multiple folders back, add extra ---: SD --- will go 3 folders back.

If you don't want this function, you can change it with set COMMAND=CD /D in the SETTINGS section SpeedDial.ini.



Installation
  • Download the zipfile and unzip the script and SpeedDial.ini in one of the folders in your CMD path
    ( echo %PATH% to find out which folders are suitable)
  • Download ES.exe from here and place it somewhere on your system.
  • Download WSelect from here, unzip it and copy WSelect.exe to the same folder where SD.cmd is (you don't need the other files).
    I tested with the 64-bit version, but the 32-bit version should be OK too
  • Open SpeedDial.ini in your favourite text-editor and change the settings to match your situation.
    At a minimum, change set ES=C:\TOOLS\EVERYTHING\ES.EXE to the correct location
  • Start CMD
  • Type
    SD
    + ENTER for a help screen.

(*) I renamed QCD to SD as that is quicker to type and I use the SpeedDial function the most.
... and to prevent having a bunch of lawyers from the original QCD chasing me .... :)
But you can rename it to anything you like. Name it GO.cmd, TO.cmd .. doesn't matter. The help will adapt accordingly.


Latest version: 1.3:
You do not have the required permissions to view the files attached to this post.
Last edited by NotNull on Tue Aug 06, 2019 11:32 am, edited 8 times in total.

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Fri Jul 05, 2019 9:45 am

Version 1.2:
  • Instead of using popd, you can now also use
    SD -
    to go one folder back.
    For multiple folders back, add extra ---:
    SD ---
    will go 3 folders back.
  • Workaround: 2install was seen as a (SpeedDial) number by CMD. New detection method.

New version can be found in the original message (replaced the first version).

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Sun Aug 04, 2019 11:20 pm

Version 1.3:
  • Added parameter handlin; /something adn -something: show Syntax
  • Moved settings to separate SpeedDial.ini file
  • Added extra speeddial 'aliases'. Example: SD pics to go to D:\Data\photos
  • Addded search limiters (exclude cetrain folders; include only certain folders)
  • Worked around ES -getresultcount so SpeedDial can now work with most.older
    Everything and ES versions (tested with Everything 1.4.1.877 and ES 1.1.0.8)
  • Combined 3 ES queries into one
  • Code optimization
(more details will follow)

New version can be found in the original message (replaced the previous one).

therube
Posts: 2308
Joined: Thu Sep 03, 2009 6:48 pm

Re: "Change directory" option for command line

Post by therube » Mon Aug 19, 2019 6:30 pm

Some time ago (August 2019) I started looking at this...
I have more looking to do, but my time is limited.
So it's time to "dump" it in it's current state. Till I get some more time to tinker with it... :)
I'm getting confused, so babble... (oh, & quite the babble it is, because I'm not even recalling currently just what I was babbling about)

Anyhow... XP, so that may play in, & spaces in filenames/search, like "my documents", as in not returning expected results...


space in filenames; "my documents"?
'my doc' (without quotes [or ticks], only a space) fails
"my doc" (with quotes) works "up top", but then

why wfn: & then with * ... * on top of that?
that returns: "smashmouth"

somewhere after QUERY is set

Code: Select all

E:\Documents and Settings\RUBEN>es /ad wfn:*outh s*
M:\_C\Damien Rice - 9\Smashmouth
X:\_MUSIC\_C\Damien Rice - 9\Smashmouth


C:\BIN>qq outh s
QUERY=/ad -n 10 -sort runcount wfn:*outh s*
/ad -n 10 -sort runcount wfn:*outh s*

outh s
Press any key to continue . . .
M:\_C\Damien Rice - 9\Smashmouth
X:\_MUSIC\_C\Damien Rice - 9\Smashmouth
Press any key to continue . . .


C:\BIN>qq my doc
QUERY=/ad -n 10 -sort runcount wfn:*my doc*
/ad -n 10 -sort runcount wfn:*my doc*

my doc
Press any key to continue . . .
Press any key to continue . . .

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Mon Aug 19, 2019 9:06 pm

It was designed for just one (1) argument (=partial foldername).
If you gave 2 arguments (my and doc), you should get the helptext.

If you want to pass "my doc" as one partial foldername you can do :
sd my?doc
or
sd my*doc



The wfn: was added because during testing there were some cases where the whole path was searched; not just the foldername. Can't remember how/when/what.


Thanks for testing, btw!

NotNull
Posts: 1395
Joined: Wed May 24, 2017 9:22 pm

Re: "Change directory" option for command line

Post by NotNull » Tue Sep 03, 2019 9:51 pm

The wfn: was added because during testing there were some cases where the whole path was searched; not just the foldername. Can't remember how/when/what.
... but now I do:
If you search for "\prog" to find all folders starting with prog (like "c:\program files"), it would also find all subfolders of that folder. (but searching for prog\ to find all folders ending with prog fails)

I'll try to come up with a better solution.


BTW: Is it useful to post new updates? Is anyone using this (besides myself)?

Post Reply