Combine 2 batches -> 1 batch... (help)

Discussion in 'Scripting' started by moozillaaa, Dec 15, 2011.

  1. moozillaaa

    moozillaaa MDL Novice

    May 9, 2011
    14
    0
    0
    I'm in the middle of using 2 batch files to rename files (about 8,000+), like so:

    The first script deletes all filename characters, except the first 2, as I want, IF I HIDE FILE EXTENSIONS BEFORE EXECUTING (that's another issue I think).
    ==================================
    Setlocal EnableDelayedExpansion

    For %%A In ( "K:\01_02A") Do (

    PushD "%%A"

    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (

    Set _tmp=%%I

    Set _tmp=!_tmp:~0,2!

    Ren "%%I" "!_tmp! "

    )

    PopD

    )
    =============================================
    More ancillary info: this above script makes the file, an MPEG file, un-identifiable to Windows. The icon for the file changes to indicate that it is un-associated with an app to open it.

    SO...

    I THEN use the second script to add TO the new 2-digit filename, 5 characters that restores the recognition of the file type, and its' association with an application (the icon changes back), and of course, the extension hides itself as I at first had it set.
    =======================================
    Setlocal EnableDelayedExpansion

    For %%A In ( "K:\01_02A") Do (

    PushD "%%A"

    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (

    Set _tmp=%%I

    Set _tmp=!_tmp:~0,-3!*.mpeg!

    Ren "%%I" "!_tmp! "

    )

    PopD

    )
    =============================================

    What will a file look like with functions combined???

    Thanks..............
     
  2. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #2 stevemk14ebr, Dec 15, 2011
    Last edited by a moderator: Apr 20, 2017
    this is simple you can just put a "pause" command between you 2 scripts to run them, so that you can prompt when you want to run the second should look like:
    Setlocal EnableDelayedExpansion
    Code:
    For %%A In ( "K:\01_02A") Do (
    
    PushD "%%A"
    
    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (
    
    Set _tmp=%%I
    
    Set _tmp=!_tmp:~0,2!
    
    Ren "%%I" "!_tmp! "
    
    )
    
    PopD
    
    )
    
    pause
    
    Setlocal EnableDelayedExpansion
    
    For %%A In ( "K:\01_02A") Do (
    
    PushD "%%A"
    
    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (
    
    Set _tmp=%%I
    
    Set _tmp=!_tmp:~0,-3!*.mpeg!
    
    Ren "%%I" "!_tmp! "
    
    )
    
    PopD
    
    )
    
    P.S i don't do complex things with script so i don't know if this will work, but logic tells me it would
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. moozillaaa

    moozillaaa MDL Novice

    May 9, 2011
    14
    0
    0
    #3 moozillaaa, Dec 16, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    It worked there, Mr stevemk ... with a pause. Thanks.

    What it did (and some might know already), was in the 'popup' command line window, was to execute the first function, then it 'paused', with a CLI message to 'Press any key to continue'.

    I did, and it executed the second function.

    Is there another parameter / switch / syntax which makes the second task execute in continuity???

     
  4. moozillaaa

    moozillaaa MDL Novice

    May 9, 2011
    14
    0
    0
    HA - I started googling again, and all the return hits are lit up!!! :eek: (from today's searching)
     
  5. moozillaaa

    moozillaaa MDL Novice

    May 9, 2011
    14
    0
    0
    o_O :eek: :eek: :dontgetit:

    YIKES.

    It does NOT take long to make a mess if you get something wrong in a script file.

    It does not take long to figure out what you did wrong too.

    It takes much longer to fix it.

    UGH.

    Help?
     
  6. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #6 stevemk14ebr, Dec 17, 2011
    Last edited by a moderator: Apr 20, 2017
    so the issue is what, you want it to execute continually, to do that i would use my same code above but try removing the pause and just leaving a space in it's place so:
    Code:
    For %%A In ( "K:\01_02A") Do (
    
    PushD "%%A"
    
    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (
    
    Set _tmp=%%I
    
    Set _tmp=!_tmp:~0,2!
    
    Ren "%%I" "!_tmp! "
    
    )
    
    PopD
    
    )
    
    
    
    Setlocal EnableDelayedExpansion
    
    For %%A In ( "K:\01_02A") Do (
    
    PushD "%%A"
    
    For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B *') Do (
    
    Set _tmp=%%I
    
    Set _tmp=!_tmp:~0,-3!*.mpeg!
    
    Ren "%%I" "!_tmp! "
    
    )
    
    PopD
    
    )
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...