• Command window : change its title after changing directory ?

    From R.Wieser@21:1/5 to All on Sat Jul 2 21:23:49 2022
    Hello all,

    I would like to have the command window the name of the current folder (I
    often have multiple ones open / on the taskbar). For that I've got a
    command replacement like this :

    doskey cd=cd /d $* ^&^& d:\owncmds\dos\SetTitle.bat

    with "SetTitle.bat" being

    For %%F in ("%CD%") do Set Title %%~nxF

    (The "For" construct because it cannot seem to apply "~nx" on an environment variable)

    This works.


    I would like to get rid of the "SetTitle" batchfile though. The problem
    with that is when I replace the calling of that batchfile with its contents (and change "%CD%" to "%%CD%%") the name of the command window will show the folder I just left, instead of the folder I've moved into.

    Does anyone have an idea how to fix this ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to All on Sun Jul 3 09:10:34 2022
    On Sun, 3 Jul 2022 09:00:55 +0700, JJ wrote:

    Use this.

    doskey cd=cd/d $* $T for /d ^%A in (.) do @title ^%~nxA

    Apparently, DOSKEY's `$T` special code caused the macro to somehow emit an extra ENTER key (WTH).

    Replace it with `^&` instead, just like in your original code. i.e.

    doskey cd=cd/d $* ^& for /d ^%A in (.) do @title ^%~nxA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sun Jul 3 09:00:55 2022
    On Sat, 2 Jul 2022 21:23:49 +0200, R.Wieser wrote:
    Hello all,

    I would like to have the command window the name of the current folder (I often have multiple ones open / on the taskbar). For that I've got a
    command replacement like this :

    doskey cd=cd /d $* ^&^& d:\owncmds\dos\SetTitle.bat

    with "SetTitle.bat" being

    For %%F in ("%CD%") do Set Title %%~nxF

    (The "For" construct because it cannot seem to apply "~nx" on an environment variable)

    This works.

    I would like to get rid of the "SetTitle" batchfile though. The problem
    with that is when I replace the calling of that batchfile with its contents (and change "%CD%" to "%%CD%%") the name of the command window will show the folder I just left, instead of the folder I've moved into.

    Does anyone have an idea how to fix this ?

    Regards,
    Rudy Wieser

    Use this.

    doskey cd=cd/d $* $T for /d ^%A in (.) do @title ^%~nxA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Jul 3 09:52:46 2022
    JJ,

    Use this.

    doskey cd=cd/d $* $T for /d ^%A in (.) do @title ^%~nxA
    ...
    Apparently, DOSKEY's `$T` special code caused the macro to somehow
    emit an extra ENTER key (WTH).

    Replace it with `^&` instead, just like in your original code. i.e.

    Alas, both fail with an "~nxA was unexpected at this time."

    When running that the above from within a batchfile this gets displayed :

    "c:\>doskey cd=cd/d $* & for /d ~nxA"

    IOW, the command partially disappears. :-|


    But ... you gave me a push to try to mix-and-match stuff. :-)

    It turns out that my "^$^$" can be replaced by "^$".

    Your "^%A" / "^%~nxA" doesn't quite work here, so I put "%%A" / "%%~nxA"
    back.

    I'm not sure what the "/d" for the "for" command does here. The code works with and without.

    And the source of my problem ? My usage of "%%CD%%" - replacing it with
    your "." works.


    The odd thing is that I'm sure I tried that too. But looking back I tried several ones in a test batchfile, with the old tries "neutralized" by preceeding them with a "rem" statement. Only now I realize that the "rem" only worked for the first part, with the part after the "^$^$" still being executed - and throwing an error. Which threw me off.


    What I ended up with and seems to work is this :

    doskey cd=cd /d $* ^& for %%A in (.) do @title %%~nxA


    Thanks for your help.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to R.Wieser on Sun Jul 3 19:45:59 2022
    On 02.07.2022 21:23, R.Wieser wrote:
    Hello all,

    I would like to have the command window the name of the current folder (I often have multiple ones open / on the taskbar). For that I've got a
    command replacement like this :

    doskey cd=cd /d $* ^&^& d:\owncmds\dos\SetTitle.bat

    with "SetTitle.bat" being

    For %%F in ("%CD%") do Set Title %%~nxF

    (The "For" construct because it cannot seem to apply "~nx" on an environment variable)

    This works.


    I would like to get rid of the "SetTitle" batchfile though. The problem
    with that is when I replace the calling of that batchfile with its contents (and change "%CD%" to "%%CD%%") the name of the command window will show the folder I just left, instead of the folder I've moved into.

    Does anyone have an idea how to fix this ?

    That was discussed a few weeks ago in alt.msdos.batch.nt


    set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Jul 3 21:40:36 2022
    Herbert,

    That was discussed a few weeks ago in alt.msdos.batch.nt

    Thank you. I've taken a peek into that newsgroup and found the thread.

    set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%

    Hmmm... Are you sure that will work ? I mean, the "set dd=cd" part isn't stored by doskey ...

    As a check I put the above in a batchfile, ran it and than looked at the command windows caption. It said "dd%". Also, "doskey /macros" shows
    "cd=cd $* &call title dd%"

    Ah, I see that "%^%dd^%%" should have been "^%%dd^%%". That fixes the environment variable, but doesn't change the "set dd=cd" problem.

    Thanks for mentioning the thread though, I'm off reading it.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Herbert Kleebauer@21:1/5 to R.Wieser on Sun Jul 3 23:26:28 2022
    On 03.07.2022 21:40, R.Wieser wrote:
    Herbert,

    That was discussed a few weeks ago in alt.msdos.batch.nt

    Thank you. I've taken a peek into that newsgroup and found the thread.

    set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%

    Hmmm... Are you sure that will work ? I mean, the "set dd=cd" part isn't stored by doskey ...

    As a check I put the above in a batchfile,

    You shouldn't have done that. Just enter it at the command prompt.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)