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

rename over a tree

Discussion in 'T&T - Scripting' started by Roedy, Oct 6, 2010.

  1. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    I would like to rename all all.bat files in a directory tree to all.btm. There is not necessarily an all.bat in each branch of the tree.

    I tried:

    global rename /E all.bat all.btm

    Without success. rename /S is for renaming dirs, not files.

    Why doesn't that work? How do you do it?
     
  2. Roedy

    Joined:
    Jun 8, 2008
    Messages:
    120
    Likes Received:
    2
    I figured out the secret. I needed:
    global /I rename /E all.bat all.btm
     
  3. WavSlave

    Joined:
    May 29, 2008
    Messages:
    47
    Likes Received:
    0
    My first thought is to add the /I switch to the GLOBAL command:

    X:\> global /i rename /e all.bat all.btm

    That switch's purpose is documented in the main help for GLOBAL.


    HTH,
    Dan McMullin
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Roedy wrote:

    | ---Quote (Originally by Roedy)---
    | global rename /E all.bat all.btm
    | ---End Quote---
    | I figured out the secret. I needed:
    | global */I *rename /E all.bat all.btm

    I presume you meant
    *global /I *rename /E all.bat all.btm

    In other words, GLOBAL and/or RENAME on your system are aliases, and you
    needed the original commands! I think you learned a valuable lesson or two
    (which I need to remember time to time myself) - when something does not
    operate as expected, check for aliases. Do not create an alias name that is
    the same as an internal command name. I very rarely do; DEL, MD and REN are
    the exceptions - I can always use ERASE, MKDIR and RENAME to get the
    original commands through their alternate names. For example, I use SWEEP as
    the basis of aliases based on the GLOBAL command.
    BTW, this thread really belongs to the TC Support forum. You ran into a
    problem trying to do something reasonably expected to be possible - that's
    just right in Support. Almost everyone who watches any of the TC fora
    watches Support, while only a few watch any of the TIPS.
    --
    Steve
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Not certain, but I suspect that the asterisks you're seeing are not Roedy's; I think they are the result of the forum smashing his boldface to fit your text-only email ...?
     
  6. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Charles Dye wrote:
    ...
    | global */I *rename /E all.bat all.btm
    ...
    | *global /I *rename /E all.bat all.btm

    | Not certain, but I suspect that the asterisks you're seeing are not
    | Roedy's; I think they are the result of the forum smashing his
    | boldface to fit your text-only email ...?

    You are correct that the OP had no asterisks. This makes my post OT. As
    to the forum doing the smashing, it is possible, and WRONG! It should never
    insert characters which have a syntactic meaning in TCC, just disguising the
    issue posted. Anyway, I just switched my profile to allow HTML from the
    forum. It was already allowed in my mail client (OE). Now I have to wait for
    other messages to see if things improve. Thanks, Charles.
    --
    Steve
     
  7. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,015
    Likes Received:
    0
    Or .....

    for /r if isfile all.bat rename all.bat all.btm

    ??
     

Share This Page