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

Author Topic: How to rename the file with file size  (Read 11598 times)

0 Members and 1 Guest are viewing this topic.

itkesavan

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows XP
    Re: How to rename the file with file size
    « Reply #15 on: December 10, 2013, 06:36:46 AM »
    Hi i tried with below batch script it is not working. from next time i will try to give better explain

    @echo off
    D:
    cd temp
    for /R %%t in (D:\temp\abc*.txt) do if %%~zt neq 0 ren "%%t" "new name%~xt"
    echo.
    echo   Done!
    pause

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: How to rename the file with file size
    « Reply #16 on: December 10, 2013, 06:48:48 AM »
    One of your % signs is not doubled.


    itkesavan

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Windows XP
      Re: How to rename the file with file size
      « Reply #17 on: December 10, 2013, 07:05:43 AM »
      Hi I tried with below batch script, it is not working. Sorry for that from next time i ill explain better.

      @echo off
      D:
      cd temp
      for /R %%t in (D:\temp\abc*.txt) do if %%~zt neq 0 ren "%%t" "new name%~xt"
      echo.
      echo   Done!
      pause


      itkesavan

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Windows XP
        Re: How to rename the file with file size
        « Reply #18 on: December 10, 2013, 07:40:20 AM »
        Sorry next time i ill explain better about problem. I have tried with below bacth script but still it is not working. Pls help me

        @echo off
        D:
        cd temp
        for /R %%t in (D:\temp\abc*.txt) do if %%~zt neq 0 ren "%%t" "new name%~xt"
        echo.
        echo   Done!
        pause


        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Re: How to rename the file with file size
        « Reply #19 on: December 10, 2013, 07:42:04 AM »
        Stop repeating yourself...
        It appears you aren't learning...and just want someone else to do it for you.
        " Anyone who goes to a psychiatrist should have his head examined. "

        itkesavan

          Topic Starter


          Rookie

          • Experience: Beginner
          • OS: Windows XP
          Re: How to rename the file with file size
          « Reply #20 on: December 10, 2013, 07:52:08 AM »
          I am learning only.... when i tried with the solution i m not getting it, so only i m asking help....

          FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

          learning now only basics....

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: How to rename the file with file size
          « Reply #21 on: December 10, 2013, 08:38:14 AM »
          Did you see my comment above? 
          English may not be your first language but if you don't understand something then ask for clarification and mention which part you don't understand.

          When a batch file doesn't perform as you expect, then describe what happened and what error messages occurred.  Help us to help you, and be interactive.

          itkesavan

            Topic Starter


            Rookie

            • Experience: Beginner
            • OS: Windows XP
            Re: How to rename the file with file size
            « Reply #22 on: December 10, 2013, 10:43:31 AM »
            @echo off
            D:
            cd temp
            for /R %%t in (D:\temp\abc*.txt) do if %%~zt neq 0 ren "%%t" "new name%~xt"
            echo.
            echo   Done!
            pause

            i need a clarification on the am i missed anything in it. because when I execute noting is happening no error message also.
            can you correct me on the above where i am wrong

            Salmon Trout

            • Guest
            Re: How to rename the file with file size
            « Reply #23 on: December 10, 2013, 10:52:16 AM »
            Quote
            "new name%~xt"

            Something wrong here

            Also after you have fixed that, if there is more than one file in d:\temp that satisfies abc*.txt, only the first will get renamed (to new name.txt), all the others will not be be renamed, and the script will halt at the first such and give an an error message:

            A duplicate file name exists, or the file
            cannot be found.




            itkesavan

              Topic Starter


              Rookie

              • Experience: Beginner
              • OS: Windows XP
              Re: How to rename the file with file size
              « Reply #24 on: December 13, 2013, 06:28:08 AM »
              yes there are 2 files in it, on that on is 0 KB. the script wat have not renames only the 0 KB file first so that only i m asking help to rename the file with file size so i can skip the 0KB file. but the above script not working pls provide any script or if any correction pls tell me....

              Night



                Greenhorn

                • Experience: Experienced
                • OS: Windows 7
                Re: How to rename the file with file size
                « Reply #25 on: December 15, 2013, 08:16:33 AM »
                Yeah, I wasn't sure what he was trying to say so I gave him a possible solution.

                patio

                • Moderator


                • Genius
                • Maud' Dib
                • Thanked: 1769
                  • Yes
                • Experience: Beginner
                • OS: Windows 7
                Re: How to rename the file with file size
                « Reply #26 on: December 15, 2013, 10:56:21 AM »
                Yeah, I wasn't sure what he was trying to say so I gave him a possible solution.

                 HuHH ? ?
                And how exactly did you do that ? ?
                " Anyone who goes to a psychiatrist should have his head examined. "

                itkesavan

                  Topic Starter


                  Rookie

                  • Experience: Beginner
                  • OS: Windows XP
                  Re: How to rename the file with file size
                  « Reply #27 on: December 17, 2013, 07:56:58 AM »
                  Any correction needs to be do on the below. because it is not working.

                  @echo off
                  D:
                  cd temp
                  for /R %%t in (D:\temp\abc*.txt) do if %%~zt neq 0 ren "%%t" "new name%~xt"
                  echo.
                  echo   Done!
                  pause


                  Lemonilla



                    Apprentice

                  • "Too sweet"
                  • Thanked: 70
                  • Computer: Specs
                  • Experience: Experienced
                  • OS: Windows 7
                  Re: How to rename the file with file size
                  « Reply #28 on: December 17, 2013, 01:49:43 PM »
                  One of your % signs is not doubled.

                  A good way to debug is to remove '@echo off', and see what actually is being run.
                  Quote from: patio
                  God Bless the DOS Helpers...
                  Quote
                  If it compiles, send the files.

                  itkesavan

                    Topic Starter


                    Rookie

                    • Experience: Beginner
                    • OS: Windows XP
                    Re: How to rename the file with file size
                    « Reply #29 on: December 19, 2013, 08:56:48 AM »
                    after i remove @echo off
                    alos it is not showing any error. Please help me with it.