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

Author Topic: Batch help  (Read 3581 times)

0 Members and 1 Guest are viewing this topic.

Jxshh

    Topic Starter


    Greenhorn

    • Experience: Beginner
    • OS: Windows 10
    Batch help
    « on: November 03, 2018, 08:46:28 PM »
    Hello;

    I have a Batch file that changes my file types from .bat to .txt for me to make some changes.

    I need it to change them to .txt files, then wait for my input, then change them back to .bat files.

    So far, it changes them to .txt files but then closes before I can make it change them back to .bat....

    Can anyone help?

    Code so far:

    dir C:\Users\joshd\Desktop\Batch
    ren *.bat *.txt
    PAUSE
    ren *.txt *.bat

    Thanks in advance!

    Jxshh

      Topic Starter


      Greenhorn

      • Experience: Beginner
      • OS: Windows 10
      Re: Batch help
      « Reply #1 on: November 03, 2018, 08:57:30 PM »
      Never Mind, after trying for an hour, I go back to it after a few minutes and spot the issue!

      dir C:\Users\joshd\Desktop\Batch
      ren *.bat *.txt
      PAUSE
      dir C:\Users\joshd\Desktop\Batch
      ren *.txt *.bat

      Missed one simple bit of code ::)

      Jxshh

        Topic Starter


        Greenhorn

        • Experience: Beginner
        • OS: Windows 10
        Re: Batch help
        « Reply #2 on: November 04, 2018, 12:12:41 AM »
        Nope, this has stopped working now....

        Can anybody advise why? It changes them from .bat to .txt but then closes, it doesn't pause or change them back for me....

        Any help please!?

        Salmon Trout

        • Guest
        Re: Batch help
        « Reply #3 on: November 04, 2018, 02:02:40 AM »
        Is this the folder where the bat -> txt operation is supposed to happen? C:\Users\joshd\Desktop\Batch\ ...?

        If the current folder is not the same one, you either need to CD into it, or use the full path to the files you want to rename. You can find out the current folder
        by using echo %cd% in your script.

        Either do this

        CD C:\Users\joshd\Desktop\Batch
        ren *.bat *.txt


        or this

        ren C:\Users\joshd\Desktop\Batch\*.bat *.txt
        ren C:\Users\joshd\Desktop\Batch\*.txt *.bat



        « Last Edit: November 04, 2018, 02:15:58 AM by Salmon Trout »

        Jxshh

          Topic Starter


          Greenhorn

          • Experience: Beginner
          • OS: Windows 10
          Re: Batch help
          « Reply #4 on: November 04, 2018, 01:21:06 PM »
          Yes, this is where the files are located that I need renaming. I will try this when I next get a chance and will get back to you.

          Thanks

          DaveLembke



            Sage
          • Thanked: 662
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Batch help
          « Reply #5 on: November 04, 2018, 04:03:48 PM »
          Curious what the need is for a batch script like this to switch batch files to text and back to batch?  ???

          Jxshh

            Topic Starter


            Greenhorn

            • Experience: Beginner
            • OS: Windows 10
            Re: Batch help
            « Reply #6 on: November 04, 2018, 11:42:08 PM »
            Curious what the need is for a batch script like this to switch batch files to text and back to batch?  ???

            I have a bat file that opens multiple Word documents for me, but I need to change the number at the end of the file name each time I run it.

            I've been told there is no way for it to do it automatically so I need to do it manually.

            So I:

            Change them to Text files
            Change the numbers
            Change them back to Bat files
            Run the Bat to open the word documents....

            DaveLembke



              Sage
            • Thanked: 662
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Batch help
            « Reply #7 on: November 05, 2018, 12:29:38 PM »
            If your editing the contents within the batch file manually, you can do this as a .BAT without switching it to .TXT

            If you Right-Click on the Batch file and then select EDIT it will open in Notepad without having to rename file extensions each time. Just have to be careful when saving the edited version of this that its saved with .BAT as the file extension and not .TXT

            Lastly, I'd save a backup copy of all batches in a folder somewhere else so that if you accidentally mess up the batch file you have a known good batch to go back to and copy from the backed up version to the working folder where your batches are edited and run from.

            Salmon Trout

            • Guest
            Re: Batch help
            « Reply #8 on: November 05, 2018, 12:43:52 PM »
            I've been told there is no way for it to do it automatically so I need to do it manually.

            There is almost certainly a way to do this.

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            Re: Batch help
            « Reply #9 on: November 05, 2018, 06:37:04 PM »
            Change them to Text files
            Change the numbers
            Change them back to Bat files
            Run the Bat to open the word documents....
            Can't say I have ever renamed the file extension of a bat file to edit it.  By default, notepad will edit batch files when you right click on the file and chose edit.