1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

General questions

Discussion in 'Support' started by CSGalloway@nc.rr.com, Aug 29, 2009.

  1. Hello,

    1) Is it possible to contine the current session once TCEXIT.BTM has been called?

    2) I have a series of statements to be run in a global routine. After adding a few more statements I now get an error so what is the best way to correct this?

    Global /i /q gosub do_fldr
    Global /i /q (some other call)

    :do_fldr
    statements
    return

    TCMD 8/9/10 under XP Pro sp3 IE7
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,938
    Likes Received:
    30
    (Why?) I'd guess not. But I suppose you could "start /B /PGM "%COMSPEC" from TCEXIT. It wouldn't be the same instance but it would inherit the environment.
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,300
    Likes Received:
    39
    You're aware that DO supports /S now, right? In a batch file, DO /S is probably preferable to GLOBAL in most cases. I tend to think of GLOBAL as a hack for the benefit of not-very-smart externals, not as a feature to use regularly.
     
  4. It needs to be backward compatible back to 8.02..... DO /S hasn't been available that far back...
    ----- Original Message -----
    From: Charles Dye
    To: CSGalloway@nc.rr.com
    Sent: Saturday, August 29, 2009 08:18 PM
    Subject: RE: [Support-t-1351] Re: General questions


    Quote:
    Originally Posted by CSGalloway@nc.rr.com
    2) I have a series of statements to be run in a global routine. After adding a few more statements I now get an error so what is the best way to correct this?

    You're aware that DO supports /S now, right? In a batch file, DO /S is probably preferable to GLOBAL in most cases. I tend to think of GLOBAL as a hack for the benefit of not-very-smart externals, not as a feature to use regularly.
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    Charles S. Galloway:
    | I have a series of statements to be run in a global routine.
    | After adding a few more statements I now get an error so what is the
    | best way to correct this?

    Charles Dye:
    | You're aware that DO supports /S now, right? In a batch file,
    | DO /S is probably preferable to GLOBAL in most cases. I tend to think
    | of GLOBAL as a hack for the benefit of not-very-smart externals, not
    | as a feature to use regularly.

    Charles S. Galloway:
    | It needs to be backward compatible back to 8.02..... DO /S
    | hasn't been available that far back...

    DO /S is available in 4NT 8.02. The equivalent of the /N option of the
    GLOBAL command (not used by the OP) became available in the DO
    command only in V10, and /J not yet. The /H option can be emulated by
    the /A: option.
    --
    HTH, Steve
     
  6. I see

    DO varname IN [range...] [/I:"text" /S[n] /A:[[-|+]rhsadecijopt] fileset

    but wouldn't GLOBAL be easier as I have several

    FOR %fn in (whatever) ren "%fn" "newname"
    ....

    so wouldn't I have to use one one DO statement with each REN statement.

    ================================I have currently:

    for %drv in ( %_HDRIVES ) (
    cdd %drv\CSG_PICS
    msgbox OK "FIXJPGS" "In %_CWD"
    :here1
    global /i gosub DoFldr
    if "%1" ne "" goto :here2
    cdd -
    )


    ================================ ----- Original Message -----
    From: Steve Fábián
    To: CSGalloway@nc.rr.com
    Sent: Saturday, August 29, 2009 11:26 PM
    Subject: RE: [Support-t-1351] Re: General questions


    Charles S. Galloway:
    | I have a series of statements to be run in a global routine.
    | After adding a few more statements I now get an error so what is the
    | best way to correct this?

    Charles Dye:
    | You're aware that DO supports /S now, right? In a batch file,
    | DO /S is probably preferable to GLOBAL in most cases. I tend to think
    | of GLOBAL as a hack for the benefit of not-very-smart externals, not
    | as a feature to use regularly.

    Charles S. Galloway:
    | It needs to be backward compatible back to 8.02..... DO /S
    | hasn't been available that far back...

    DO /S is available in 4NT 8.02. The equivalent of the /N option of the
    GLOBAL command (not used by the OP) became available in the DO
    command only in V10, and /J not yet. The /H option can be emulated by
    the /A: option.
    --
    HTH, Steve
     
  7. I sent the last reply too quickly - sorry....
    ===================I see

    DO varname IN [range...] [/I:"text" /S[n] /A:[[-|+]rhsadecijopt] fileset

    but wouldn't GLOBAL be easier as I have several

    FOR %fn in (whatever) ren "%fn" "newname"
    ....

    so wouldn't I have to use one one DO statement with each REN statement.

    ================================I have currently:

    for %drv in ( %_HDRIVES ) (
    cdd %drv\CSG_PICS
    msgbox OK "FIXJPGS" "In %_CWD"
    :here1
    global /i gosub DoFldr
    if "%1" ne "" goto :here2
    cdd -
    )


    :DoFldr
    for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren "%fn" %@left[-15,%@name["%fn"]].jpg
    for %fn in ("*%nbsp;*.jpg") ren "%fn" "%@replace[%nbsp;,_,%fn]"
    for %fn in ("* *.jpg") ren "%fn" "%@replace[ ,_,%fn]"
    for %fn in ("*ª*.jpg") ren "%fn" "%@replace[ª,_,%fn]"
    for %fn in ("*'*.jpg") ren "%fn" "%@replace[',_,%fn]"
    for %fn in ("*-*.jpg") ren "%fn" "%@replace[-,_,%fn]"
    :: for %fn in ("*`*.jpg") ren "%fn" "%@replace[`,_,%fn]"
    for %fn in ("*~*.jpg") ren "%fn" "%@replace[~,_,%fn]"
    for %fn in ("*__*.jpg") ren "%fn" "%@replace[__,_,%fn]"
    for %fn in ("* _*.jpg") ren "%fn" "%@replace[ _,_,%fn]"
    for %fn in ("*_ *.jpg") ren "%fn" "%@replace[_ ,_,%fn]"
    RETURN

    ================================ ----- Original Message -----
    From: Steve Fábián
    To: CSGalloway@nc.rr.com
    Sent: Saturday, August 29, 2009 11:26 PM
    Subject: RE: [Support-t-1351] Re: General questions


    Charles S. Galloway:
    | I have a series of statements to be run in a global routine.
    | After adding a few more statements I now get an error so what is the
    | best way to correct this?

    Charles Dye:
    | You're aware that DO supports /S now, right? In a batch file,
    | DO /S is probably preferable to GLOBAL in most cases. I tend to think
    | of GLOBAL as a hack for the benefit of not-very-smart externals, not
    | as a feature to use regularly.

    Charles S. Galloway:
    | It needs to be backward compatible back to 8.02..... DO /S
    | hasn't been available that far back...

    DO /S is available in 4NT 8.02. The equivalent of the /N option of the
    GLOBAL command (not used by the OP) became available in the DO
    command only in V10, and /J not yet. The /H option can be emulated by
    the /A: option.
    --
    HTH, Steve
     
  8. I still haven't gotten a good reply about this. Right now this is what I have:

    == beging paste =:: if param passed - do current folder tree
    :: else do \CSG_PICS in each Hard Drive....
    ::
    if "%1" ne "" goto here1

    for %drv in ( %_HDRIVES ) (
    cdd "%drv%\CSG_PICS"
    :here1
    msgbox OK "FIXJPGS" "In %_CWD"
    global /i /q gosub DoFldr
    if "%1" ne "" goto here2
    cdd -
    )

    Goto here2

    :DoFldr
    echo %_CWD
    for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren "%fn" %@left[-15,%@name["%fn"]].jpg
    for %fn in ("*%nbsp;*.jpg") ren "%fn" "%@replace[%nbsp;,_,%fn]"
    for %fn in ("* *.jpg") ren "%fn" "%@replace[ ,_,%fn]"
    for %fn in ("*ª*.jpg") ren "%fn" "%@replace[ª,_,%fn]"
    for %fn in ("*'*.jpg") ren "%fn" "%@replace[',_,%fn]"
    for %fn in ("*-*.jpg") ren "%fn" "%@replace[-,_,%fn]"
    :: for %fn in ("*`*.jpg") ren "%fn" "%@replace[`,_,%fn]"
    for %fn in ("*~*.jpg") ren "%fn" "%@replace[~,_,%fn]"
    for %fn in ("*__*.jpg") ren "%fn" "%@replace[__,_,%fn]"
    for %fn in ("* _*.jpg") ren "%fn" "%@replace[ _,_,%fn]"
    for %fn in ("*_ *.jpg") ren "%fn" "%@replace[_ ,_,%fn]"
    RETURN

    :here2
    :========================================================= end paste =
    When I call with no param it says:

    [D:\]c:\BATCH\FIXJPGS.BTM

    [D:\CSG_PICS]

    It should be saying
    [D:\]c:\BATCH\FIXJPGS.BTM
    C:\CSG_PICS
    C:\CSG_PICS\Dir1
    C:\CSG_PICS\Dir2
    D:\CSG_PICS\
    D:\CSG_PICS\Dir1
    D:\CSG_PICS\Dir2
    ----- Original Message -----
    From: CSGalloway@nc.rr.com
    To: CSGalloway@nc.rr.com
    Sent: Sunday, August 30, 2009 09:28 PM
    Subject: RE: [Support-t-1351] Re: General questions


    I sent the last reply too quickly - sorry....
    ===================I see

    DO varname IN [range...] [/I:"text" /S[n] /A:[[-|+]rhsadecijopt] fileset

    but wouldn't GLOBAL be easier as I have several

    FOR %fn in (whatever) ren "%fn" "newname"
    ....

    so wouldn't I have to use one one DO statement with each REN statement.

    ================================I have currently:

    for %drv in ( %_HDRIVES ) (
    cdd %drv\CSG_PICS
    msgbox OK "FIXJPGS" "In %_CWD"
    :here1
    global /i gosub DoFldr
    if "%1" ne "" goto :here2
    cdd -
    )


    oFldr
    for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9][0-9][0-9].jpg) ren "%fn" %@left[-15,%@name["%fn"]].jpg
    for %fn in ("*%nbsp;*.jpg") ren "%fn" "%@replace[%nbsp;,_,%fn]"
    for %fn in ("* *.jpg") ren "%fn" "%@replace[ ,_,%fn]"
    for %fn in ("*ª*.jpg") ren "%fn" "%@replace[ª,_,%fn]"
    for %fn in ("*'*.jpg") ren "%fn" "%@replace[',_,%fn]"
    for %fn in ("*-*.jpg") ren "%fn" "%@replace[-,_,%fn]"
    :: for %fn in ("*`*.jpg") ren "%fn" "%@replace[`,_,%fn]"
    for %fn in ("*~*.jpg") ren "%fn" "%@replace[~,_,%fn]"
    for %fn in ("*__*.jpg") ren "%fn" "%@replace[__,_,%fn]"
    for %fn in ("* _*.jpg") ren "%fn" "%@replace[ _,_,%fn]"
    for %fn in ("*_ *.jpg") ren "%fn" "%@replace[_ ,_,%fn]"
    RETURN

    ================================ ----- Original Message -----
    From: Steve Fábián
    To: CSGalloway@nc.rr.com
    Sent: Saturday, August 29, 2009 11:26 PM
    Subject: RE: [Support-t-1351] Re: General questions


    Charles S. Galloway:
    | I have a series of statements to be run in a global routine.
    | After adding a few more statements I now get an error so what is the
    | best way to correct this?

    Charles Dye:
    | You're aware that DO supports /S now, right? In a batch file,
    | DO /S is probably preferable to GLOBAL in most cases. I tend to think
    | of GLOBAL as a hack for the benefit of not-very-smart externals, not
    | as a feature to use regularly.

    Charles S. Galloway:
    | It needs to be backward compatible back to 8.02..... DO /S
    | hasn't been available that far back...

    DO /S is available in 4NT 8.02. The equivalent of the /N option of the
    GLOBAL command (not used by the OP) became available in the DO
    command only in V10, and /J not yet. The /H option can be emulated by
    the /A: option.
    --
    HTH, Steve
     
  9. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,187
    Likes Received:
    11
    You can also simplify things using delayed variable expansion.
    This command: ren "* *.jpg" "%%@replace[ ,_,*]"

    renames all the JPG files that have a space in their name.

    [C:\Temp\foo] dir

    Volume in drive C is unlabeled Serial number is 5013:eee9
    Directory of C:\Temp\foo\*

    9/04/2009 10:30 <DIR> .
    9/04/2009 10:30 <DIR> ..
    9/04/2009 10:18 0 file1-12345.jpg
    9/04/2009 10:19 0 file2_ 12345.jpg
    9/04/2009 10:19 0 file3 _12345.jpg
    9/04/2009 10:19 0 file4 _12345.jpg
    9/04/2009 10:20 0 file5'12345.jpg
    9/04/2009 10:19 0 file6~12345.jpg
    9/04/2009 10:17 0 file10_ 12345.jpg
    9/04/2009 10:17 0 file11 _12345.jpg
    9/04/2009 10:17 0 file12_ 12345.jpg
    0 bytes in 9 files and 2 dirs
    48,804,290,560 bytes free

    [C:\Temp\foo] ren "* *.jpg" "%%@replace[ ,_,*]"
    C:\Temp\foo\file10_ 12345.jpg -> C:\Temp\foo\file10__12345.jpg
    C:\Temp\foo\file11 _12345.jpg -> C:\Temp\foo\file11__12345.jpg
    C:\Temp\foo\file12_ 12345.jpg -> C:\Temp\foo\file12__12345.jpg
    C:\Temp\foo\file2_ 12345.jpg -> C:\Temp\foo\file2__12345.jpg
    C:\Temp\foo\file3 _12345.jpg -> C:\Temp\foo\file3__12345.jpg
    C:\Temp\foo\file4 _12345.jpg -> C:\Temp\foo\file4__12345.jpg
    6 files renamed

    -Scott


    "CSGalloway@nc.rr.com" <> wrote on 09/04/2009
    02:18:26 AM:


    fileset

    statement.

    think

     
  10. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,187
    Likes Received:
    11
    I uncovered an anomaly with delayed variable expansion and filenames that
    contain a tilde character.

    This directory contains 9 files. Only one has a tilde in its name.

    [C:\Temp\foo] dir

    Volume in drive C is unlabeled Serial number is 5013:eee9
    Directory of C:\Temp\foo\*

    9/04/2009 10:40 <DIR> .
    9/04/2009 10:40 <DIR> ..
    9/04/2009 10:18 0 file1-12345.jpg
    9/04/2009 10:19 0 file2__12345.jpg
    9/04/2009 10:19 0 file3__12345.jpg
    9/04/2009 10:19 0 file4__12345.jpg
    9/04/2009 10:20 0 file5'12345.jpg
    9/04/2009 10:19 0 file6~12345.jpg
    9/04/2009 10:17 0 file10__12345.jpg
    9/04/2009 10:17 0 file11__12345.jpg
    9/04/2009 10:17 0 file12__12345.jpg
    0 bytes in 9 files and 2 dirs
    48,804,200,448 bytes free

    [C:\Temp\foo] ren "*~*.jpg" "%%@replace[~,_,*]"
    C:\Temp\foo\file1-12345.jpg -> C:\Temp\foo\file1-12345.jpg
    C:\Temp\foo\file10__12345.jpg -> C:\Temp\foo\file10__12345.jpg
    C:\Temp\foo\file11__12345.jpg -> C:\Temp\foo\file11__12345.jpg
    C:\Temp\foo\file12__12345.jpg -> C:\Temp\foo\file12__12345.jpg
    C:\Temp\foo\file2__12345.jpg -> C:\Temp\foo\file2__12345.jpg
    C:\Temp\foo\file3__12345.jpg -> C:\Temp\foo\file3__12345.jpg
    C:\Temp\foo\file4__12345.jpg -> C:\Temp\foo\file4__12345.jpg
    C:\Temp\foo\file5'12345.jpg -> C:\Temp\foo\file5'12345.jpg
    C:\Temp\foo\file6~12345.jpg -> C:\Temp\foo\file6_12345.jpg
    9 files renamed

    Actually, tilde isn't matched on the command line with TAB completion
    either.

    -Scott


    "CSGalloway@nc.rr.com" <> wrote on 09/04/2009
    02:18:26 AM:


    fileset

    statement.

    think

     

Share This Page