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

Author Topic: [solved] Create 100 files in a folder  (Read 13663 times)

0 Members and 1 Guest are viewing this topic.

Esgrimidor

    Topic Starter


    Hopeful

    Thanked: 1
    [solved] Create 100 files in a folder
    « on: August 22, 2009, 03:31:52 AM »
    Create 100 files in a folder

    I need create 100 files in a folder.
    The bat may ask the path of the folder. Create if not exists. Proposing the last one used.

    The files to create have this structure : prefix.800.bat , where 800 take values from 800 to 899 .

    The bat may ask the prefix. By example : pepe

    The content of the bat files is slightly different

    The general content is :

    echo off
    taskkill.exe /im gmw5.exe /f
    Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\prefix.800
    exit


    Where prefix = pepe
    and 800 goes from 800 to 899 corresponding to the name of the bat

    That is : pepe.800.bat -> pepe.800

    ....................................... ................
                  pepe.899.bat -> pepe.899

    ******************************

    The bat procedure :

    1. Ask for the path where the 100 files will be.
    2. Ask for the prefix
    3. Generate the 100 files....


    thanksssxxx
    « Last Edit: August 22, 2009, 01:02:30 PM by Esgrimidor »
    No dejes que tu felicidad dependa de lo que no depende de tí.

    smeezekitty

    • Guest
    Re: Create 100 files in a folder
    « Reply #1 on: August 22, 2009, 11:25:52 AM »
    empty files?
    what do you want the files to contain?

    BatchFileBasics



      Hopeful

      Thanked: 18
      Re: Create 100 files in a folder
      « Reply #2 on: August 22, 2009, 11:27:26 AM »
      so, are you asking to create files
      pre.800 - pre.899?

      no .bat ext?

      Code: [Select]
      @echo off
      :begin
      set pth=
      echo.
      set /p pth=Path of folder:
      if not exist "%pth%" (
      mkdir "%pth%"
      goto :PRE
      )
      echo.
      echo ERROR: Folder exists
      goto :begin
      :PRE
      set /p pr=Prefix for files:
      echo.
      echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
      pause
      cd "%pth%"
      for /l %%a in (800,1,899) do (
      echo @echo off>%pr%.%%a
      echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a
      echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a
      echo exit>>%pr%.%%a
      )
      When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

      Esgrimidor

        Topic Starter


        Hopeful

        Thanked: 1
        Re: Create 100 files in a folder
        « Reply #3 on: August 22, 2009, 11:57:39 AM »
        empty files?
        what do you want the files to contain?



        "The files to create have this structure : prefix.800.bat , where 800 take values from 800 to 899 ."

        So are bat files.


        By example : pepe.800.bat have this content :

        echo off
        taskkill.exe /im gmw5.exe /f
        Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.800
        exit

        and pepe.801.bat have this :

        echo off
        taskkill.exe /im gmw5.exe /f
        Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.801
        exit

        and so on to the value 899 .

        "so, are you asking to create files
        pre.800 - pre.899?

        no .bat ext?"

        extension .bat


        *********
        I try again :

        I need generate 100 bat files

        prefix.800.bat to prefix.899.bat where prefix is a variable. By example prefix=pepe

        Each bat file have a similar content, only vary the archive prefix.800 where 800 vary from 800 to 899.

        prefix is a variable. By example prefix=pepe


        by example :
        The file pepe.850.bat have this content :

        echo off
        taskkill.exe /im gmw5.exe /f
        Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.850
        exit

        Thanksxxx




        No dejes que tu felicidad dependa de lo que no depende de tí.

        Salmon Trout

        • Guest
        Re: Create 100 files in a folder
        « Reply #4 on: August 22, 2009, 12:00:28 PM »
        Quote from: I try again :
        I try again :

         ::)

        BatchFileBasics



          Hopeful

          Thanked: 18
          Re: Create 100 files in a folder
          « Reply #5 on: August 22, 2009, 12:04:53 PM »
          ok, sorry, the
          Quote
          Where prefix = pepe
          and 800 goes from 800 to 899 corresponding to the name of the bat

          That is : pepe.800.bat -> pepe.800

          ....................................... ................
                        pepe.899.bat -> pepe.899

          so let me do this again  ::)

          Code: [Select]
          @echo off
          :begin
          set pth=
          echo.
          set /p pth=Path of folder:
          if not exist "%pth%" (
          mkdir "%pth%"
          goto :PRE
          )
          echo.
          echo ERROR: Folder exists
          goto :begin
          :PRE
          set /p pr=Prefix for files:
          echo.
          echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
          pause
          cd "%pth%"
          for /l %%a in (800,1,899) do (
          echo @echo off>%pr%.%%a.bat
          echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
          echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
          echo exit>>%pr%.%%a.bat
          )
          When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

          Esgrimidor

            Topic Starter


            Hopeful

            Thanked: 1
            Re: Create 100 files in a folder
            « Reply #6 on: August 22, 2009, 12:05:49 PM »
            I try the script.

            I think is going well. Now comment.
            No dejes que tu felicidad dependa de lo que no depende de tí.

            Esgrimidor

              Topic Starter


              Hopeful

              Thanked: 1
              Re: Create 100 files in a folder
              « Reply #7 on: August 22, 2009, 12:07:41 PM »
              I comment on the first one :

              I can't paste in the command window the path I want .

              It's possible prepare this ?

              I try the second.
               ::)
              No dejes que tu felicidad dependa de lo que no depende de tí.

              Esgrimidor

                Topic Starter


                Hopeful

                Thanked: 1
                Re: Create 100 files in a folder
                « Reply #8 on: August 22, 2009, 12:09:30 PM »
                ::)



                You are quite right. I only try to reproduce a script.
                No dejes que tu felicidad dependa de lo que no depende de tí.

                BatchFileBasics



                  Hopeful

                  Thanked: 18
                  Re: Create 100 files in a folder
                  « Reply #9 on: August 22, 2009, 12:10:10 PM »
                  are you pressing ctrl + v? because that does not work.

                  right click the window > paste.

                  or you can just type it in manually
                  When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

                  Esgrimidor

                    Topic Starter


                    Hopeful

                    Thanked: 1
                    Re: Create 100 files in a folder
                    « Reply #10 on: August 22, 2009, 12:16:04 PM »
                    Okis.


                    The files are created in the present folder not in the folder indicated.

                    I try with Y:\prueba , but the files were written in the dektop folder in :

                    M:\Documents and Settings\JOSE\Escritorio\

                    No dejes que tu felicidad dependa de lo que no depende de tí.

                    BatchFileBasics



                      Hopeful

                      Thanked: 18
                      Re: Create 100 files in a folder
                      « Reply #11 on: August 22, 2009, 12:17:19 PM »
                      oh my, i should of fixed that,  :P

                      Code: [Select]
                      @echo off
                      :begin
                      set pth=
                      echo.
                      set /p pth=Path of folder:
                      if not exist "%pth%" (
                      mkdir "%pth%"
                      goto :PRE
                      )
                      echo.
                      echo ERROR: Folder exists
                      goto :begin
                      :PRE
                      set /p pr=Prefix for files:
                      echo.
                      echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
                      pause
                      cd /d "%pth%"
                      for /l %%a in (800,1,899) do (
                      echo @echo off>%pr%.%%a.bat
                      echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
                      echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
                      echo exit>>%pr%.%%a.bat
                      )
                      When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

                      BC_Programmer


                        Mastermind
                      • Typing is no substitute for thinking.
                      • Thanked: 1140
                        • Yes
                        • Yes
                        • BC-Programming.com
                      • Certifications: List
                      • Computer: Specs
                      • Experience: Beginner
                      • OS: Windows 11
                      Re: Create 100 files in a folder
                      « Reply #12 on: August 22, 2009, 12:18:56 PM »
                      I'm trying to understand why multiple batch files are even necessary.
                      I was trying to dereference Null Pointers before it was cool.

                      Esgrimidor

                        Topic Starter


                        Hopeful

                        Thanked: 1
                        Re: Create 100 files in a folder
                        « Reply #13 on: August 22, 2009, 12:21:57 PM »
                        oh my, i should of fixed that,  :P

                        Code: [Select]
                        @echo off
                        :begin
                        set pth=
                        echo.
                        set /p pth=Path of folder:
                        if not exist "%pth%" (
                        mkdir "%pth%"
                        goto :PRE
                        )
                        echo.
                        echo ERROR: Folder exists
                        goto :begin
                        :PRE
                        set /p pr=Prefix for files:
                        echo.
                        echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
                        pause
                        cd /d "%pth%"
                        for /l %%a in (800,1,899) do (
                        echo @echo off>%pr%.%%a.bat
                        echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
                        echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a.bat >>%pr%.%%a.bat
                        echo exit>>%pr%.%%a.bat
                        )

                        Inside each bat file created I observed you put the extension bat to the files inside. And ther is not extension there.


                        That's :

                        pepe.850.bat

                        have the content :

                        echo off
                        taskkill.exe /im gmw5.exe /f
                        Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\pepe.850
                        exit

                        In this case don't have the extension bat inside........

                        No dejes que tu felicidad dependa de lo que no depende de tí.

                        BatchFileBasics



                          Hopeful

                          Thanked: 18
                          Re: Create 100 files in a folder
                          « Reply #14 on: August 22, 2009, 12:25:01 PM »
                          Esgrimidor, what do you need 100 batch files for anyways? 1 file, about 10 lines, and a good for loop can probably do what all these files would do..

                          and really, this is confusing me,
                          here you go
                          Code: [Select]
                          @echo off
                          :begin
                          set pth=
                          echo.
                          set /p pth=Path of folder:
                          if not exist "%pth%" (
                          mkdir "%pth%"
                          goto :PRE
                          )
                          echo.
                          echo ERROR: Folder exists
                          goto :begin
                          :PRE
                          set /p pr=Prefix for files:
                          echo.
                          echo IF THE PREFIX CONTAINS INVALID CHARACTERS, FILES WOULD NOT BE CREATED.
                          pause
                          cd /d "%pth%"
                          for /l %%a in (800,1,899) do (
                          echo @echo off>%pr%.%%a.bat
                          echo taskkill.exe /im gmw5.exe /f>>%pr%.%%a.bat
                          echo Y:\GoldminePrg\gmw5.exe /i:esm /u:JOSE /p: /m:Y:\GoldminePrg\Macros\%pr%.%%a >>%pr%.%%a.bat
                          echo exit>>%pr%.%%a.bat
                          )
                          When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.