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

Copying files in subdirectories

Discussion in 'Support' started by pb4072, Mar 7, 2016.

  1. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Hi,
    I know I can't do this with cmd.exe, so, I want to try it here. I'm sure TCC can do this for me.

    I have a directory full of subdirectories. In each subdirectory, there's a file. I've got all these files set up in here for a test sequence I need to run. Anyway, all of the files in the respective subdirectories begin with the prefix "test." I'd like to create a couple of test files. I'd like to name the existing file "test1-" instead of just "test." And, I'd like to create a second test file, called "test2-."

    Can anyone help me with this? If I'm in the parent directory, is there some way, with a regex, do a kind of "for" command, where I can creep into every sub-directory and do the above?

    Thanks!
    Peter
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    Have you looked into GLOBAL? (Hint: You usually want to use /I with this command.)
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    GLOBAL perhaps.
     
  4. Christian Albaret

    Joined:
    Jul 1, 2008
    Messages:
    154
    Likes Received:
    1
    I would do
    Code:
    for /a:d /h d in (*) ( ren %d\* "%%@replace[test,test1-,*]" )
    
    and a similar COPY command.
     
  5. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,287
    Likes Received:
    39
    But be careful not to rename the same file multiple times -- TEST.TXT to TEST1-.TXT to TEST1-1-.TXT, and so on.
     
  6. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Thank you. I get "The system cannot find the path specified."
     
  7. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    I tried "GLOBAL." I've never heard of it, but, I'm reading about it. Looks cool. But, no, I can't get it to work. It keeps saying "the parameter is incorrect."
     
  8. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Also, I can't find what "/l" means with GLOBAL.
     
  9. Charles G

    Joined:
    Apr 2, 2011
    Messages:
    1,015
    Likes Received:
    0
    Code:
    [C:\Program Files\JPSoft\TCMD19_x64]global /?
    Execute a command in the current directory and its subdirectories.
    
    GLOBAL [/H /I /J /N /P /Q /Sn] command
            /H(idden directories)   /P(rompt)
            /I(gnore exit codes)    /Q(uiet)
            /J(unctions)            /Sn (subdirectory level)
            /N(o junctions)
    
    [C:\Program Files\JPSoft\TCMD19_x64]
     
  10. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    I haven't tested this, but try:
    Code:
    global /i ren ::test(.*) ::test1-\1
    
    I'm not sure what it is you want to do with test2- however. Create an empty file? Create a copy of test1-?
     

Share This Page