Output filenames with for loop in a batch fileBatch files: Outputting into txt fileFast NT batch script for...

Is `Object` a function in javascript?

Can we "borrow" our answers to populate our own websites?

Does the US government have any planning in place to ensure there's no shortages of food, fuel, steel and other commodities?

Methods for writing a code review

Cat is tipping over bed-side lamps during the night

Crack the bank account's password!

Why avoid shared user accounts?

Why is it that Bernie Sanders is always called a "socialist"?

How do you get out of your own psychology to write characters?

Does Skippy chunky peanut butter contain trans fat?

Does diversity provide anything that meritocracy does not?

Taking headphones when quitting job

Why maximum length of IP, TCP, UDP packet is not suit?

Eww, those bytes are gross

Why is the "Domain users" group missing from this Powershell AD Query?

Square Root Distance from Integers

Why is 'diphthong' pronounced the way it is?

What can I do to encourage my players to use their consumables?

Do authors have to be politically correct in article-writing?

Which scales have a major chord built on second note? Which scales have a minor chord built on the seventh note?

Is there a way to not have to poll the UART of an AVR?

How to politely refuse in-office gym instructor for steroids and protein

Equivalent of "illegal" for violating civil law

Is there a verb that means to inject with poison?



Output filenames with for loop in a batch file


Batch files: Outputting into txt fileFast NT batch script for determining path lengths in a folderWriting time in a file in a for loopBulk rename files to name of parent folderRename files sequentially from input using batch file?CMD Command Prompt DIR Batch FileBatch rename files recovered by Photorec with their offset valuesHow to Create individual text files from a wmic outputrecursive 7Zip unzip and rename is sub directoriesHow to loop through files named in a text file? Windows Server 2012













0















I want to rename files with a batch command and capture the original and renamed files in a list in order to provide a cross reference (doing a DIR /OS >file both before and after the batch file is not rigourous enough).



The file below carries out the renaming fine, but my understanding is not good enough to get the output bit working (if it even is possible). Also, the output in the example below is different depending on whether output is to file or screen.



I want to be able to understand more of this:



@echo off
set /a c=%1
setLocal ENABLEDELAYEDEXPANSION
For %%G in (*.tif) do (
echo %%G >infile.txt
ren %%G abc.!c!.tif
set /a c=c+1
echo %%G >outfile.txt
)
endlocal









share|improve this question
















bumped to the homepage by Community 3 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I want to rename files with a batch command and capture the original and renamed files in a list in order to provide a cross reference (doing a DIR /OS >file both before and after the batch file is not rigourous enough).



    The file below carries out the renaming fine, but my understanding is not good enough to get the output bit working (if it even is possible). Also, the output in the example below is different depending on whether output is to file or screen.



    I want to be able to understand more of this:



    @echo off
    set /a c=%1
    setLocal ENABLEDELAYEDEXPANSION
    For %%G in (*.tif) do (
    echo %%G >infile.txt
    ren %%G abc.!c!.tif
    set /a c=c+1
    echo %%G >outfile.txt
    )
    endlocal









    share|improve this question
















    bumped to the homepage by Community 3 hours ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I want to rename files with a batch command and capture the original and renamed files in a list in order to provide a cross reference (doing a DIR /OS >file both before and after the batch file is not rigourous enough).



      The file below carries out the renaming fine, but my understanding is not good enough to get the output bit working (if it even is possible). Also, the output in the example below is different depending on whether output is to file or screen.



      I want to be able to understand more of this:



      @echo off
      set /a c=%1
      setLocal ENABLEDELAYEDEXPANSION
      For %%G in (*.tif) do (
      echo %%G >infile.txt
      ren %%G abc.!c!.tif
      set /a c=c+1
      echo %%G >outfile.txt
      )
      endlocal









      share|improve this question
















      I want to rename files with a batch command and capture the original and renamed files in a list in order to provide a cross reference (doing a DIR /OS >file both before and after the batch file is not rigourous enough).



      The file below carries out the renaming fine, but my understanding is not good enough to get the output bit working (if it even is possible). Also, the output in the example below is different depending on whether output is to file or screen.



      I want to be able to understand more of this:



      @echo off
      set /a c=%1
      setLocal ENABLEDELAYEDEXPANSION
      For %%G in (*.tif) do (
      echo %%G >infile.txt
      ren %%G abc.!c!.tif
      set /a c=c+1
      echo %%G >outfile.txt
      )
      endlocal






      windows cmd.exe






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 2 '14 at 13:53









      Der Hochstapler

      67.9k49230285




      67.9k49230285










      asked Apr 25 '12 at 14:00









      user130218user130218

      11




      11





      bumped to the homepage by Community 3 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 3 hours ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          After sleeping over it I found the answer to the problem. I only have to write the name of the file that is about to be renamed as I 'know' what I am about to call it! Obvious in the end.



          set /a c=%1
          set param=%2
          setLocal ENABLEDELAYEDEXPANSION
          FOR %%i in (*.tif) do (
          echo %%i >>in.txt
          ren %%i %param%!c!.tif
          echo %param%!c!.tif >>out.txt
          set /a c=c+1
          )
          endlocal


          All I need to do now is put in a test to stop it renaming again the first file it renamed (can happen depending on the number being used in var 'c' and the original file names).






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f416715%2foutput-filenames-with-for-loop-in-a-batch-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            After sleeping over it I found the answer to the problem. I only have to write the name of the file that is about to be renamed as I 'know' what I am about to call it! Obvious in the end.



            set /a c=%1
            set param=%2
            setLocal ENABLEDELAYEDEXPANSION
            FOR %%i in (*.tif) do (
            echo %%i >>in.txt
            ren %%i %param%!c!.tif
            echo %param%!c!.tif >>out.txt
            set /a c=c+1
            )
            endlocal


            All I need to do now is put in a test to stop it renaming again the first file it renamed (can happen depending on the number being used in var 'c' and the original file names).






            share|improve this answer






























              0














              After sleeping over it I found the answer to the problem. I only have to write the name of the file that is about to be renamed as I 'know' what I am about to call it! Obvious in the end.



              set /a c=%1
              set param=%2
              setLocal ENABLEDELAYEDEXPANSION
              FOR %%i in (*.tif) do (
              echo %%i >>in.txt
              ren %%i %param%!c!.tif
              echo %param%!c!.tif >>out.txt
              set /a c=c+1
              )
              endlocal


              All I need to do now is put in a test to stop it renaming again the first file it renamed (can happen depending on the number being used in var 'c' and the original file names).






              share|improve this answer




























                0












                0








                0







                After sleeping over it I found the answer to the problem. I only have to write the name of the file that is about to be renamed as I 'know' what I am about to call it! Obvious in the end.



                set /a c=%1
                set param=%2
                setLocal ENABLEDELAYEDEXPANSION
                FOR %%i in (*.tif) do (
                echo %%i >>in.txt
                ren %%i %param%!c!.tif
                echo %param%!c!.tif >>out.txt
                set /a c=c+1
                )
                endlocal


                All I need to do now is put in a test to stop it renaming again the first file it renamed (can happen depending on the number being used in var 'c' and the original file names).






                share|improve this answer















                After sleeping over it I found the answer to the problem. I only have to write the name of the file that is about to be renamed as I 'know' what I am about to call it! Obvious in the end.



                set /a c=%1
                set param=%2
                setLocal ENABLEDELAYEDEXPANSION
                FOR %%i in (*.tif) do (
                echo %%i >>in.txt
                ren %%i %param%!c!.tif
                echo %param%!c!.tif >>out.txt
                set /a c=c+1
                )
                endlocal


                All I need to do now is put in a test to stop it renaming again the first file it renamed (can happen depending on the number being used in var 'c' and the original file names).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 26 '12 at 11:19









                slhck

                161k47447470




                161k47447470










                answered Apr 26 '12 at 10:22









                user130218user130218

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f416715%2foutput-filenames-with-for-loop-in-a-batch-file%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

                    Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

                    looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...