Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: help with a bat file  (Read 2258 times)

0 Members and 1 Guest are viewing this topic.

xfusion

    Topic Starter


    Rookie

    help with a bat file
    « on: July 14, 2009, 02:56:17 AM »
    i work at a tv station and everyday we download a most of our shows for the next day from a program called pathfire, now everything we get is named ending with _std and  comes with multiple .mpg's and .idx files, now this is great and all but things we get from warner brothers come with files with no extension and .idx files, so i currently have a bat file that when run in a folder will rename all the files with no extension .mpg's

    ren *_std *_std.mpg

    now each of our shows are in different folders in a main folder for that day, now all this information is basically useless because my main question is how can i get my bat file, to go through each folder in the folder it is run in and run this command in each, so instead of copying it 6 times in each of the show folders and running it, i can just run it once in the main folder and it will go through every folder there and rename things

    hope this isent to confusing :(

    jessedz

    • Guest
    Re: help with a bat file
    « Reply #1 on: July 14, 2009, 06:48:53 AM »
    I dont know if you are familiar with de CD command, but if you type:
    CD\
    you will go to the uppest folder (C:) . if you type
    CD example
    you will go to C:\example  (if it excist...)
    you can create a .bat file like this:

    cd\
    cd example
    cd folder 1
    ren *_std   *.std.mpg
    cd\
    cd example
    cd folder 2
    ren *_std   *.std.mpg
    cd\
    cd example
    cd folder 3
    ren *_std   *.std.mpg
    cd\
    cd example
    cd folder 4
    ren *_std   *.std.mpg

    i know my english is bad... i hope its clear now

    wbrost



      Intermediate
    • Thanked: 11
      Re: help with a bat file
      « Reply #2 on: July 14, 2009, 08:29:18 AM »
      ok give this a try and let me know if you are still having issues with it.


      Code: [Select]
      @ECHO OFF
      CLS

      REM THIS WILL SCAN THE CURRENT FOLDER AND RETURN SUB-FOLDERS TO A TEXT FILE
      CD %CD%
      DIR /B *.>"%TEMP%\DIRTEST.TXT"

      REM USE DIRTEST.TXT IN A FOR LOOP
      FOR /f "delims==" %%A in (C:\DOCUME~1\%USERNAME%\LOCALS~1\Temp\DIRTEST.TXT) DO SET A=%%A& CALL :DIR %%A


      IF EXIST "%TEMP%\DIRTEST.TXT" DEL "%TEMP%\DIRTEST.TXT"
      ECHO JOB COMPLETE.....
      GOTO END

      :DIR

      ECHO WORKING ON FOLDER %A%
      CD\
      CD %A%
      REN *_std *_std.mpg


      :END

      « Last Edit: July 14, 2009, 09:05:29 AM by wbrost »