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 11570 times)

0 Members and 1 Guest are viewing this topic.

itkesavan

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows XP
    How to rename the file with file size
    « on: November 28, 2013, 07:58:58 AM »
    Pleas help me with the command for renameing the file using file size (note: i want to skip the 0KB file).

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: How to rename the file with file size
    « Reply #1 on: November 28, 2013, 04:12:50 PM »
    Supply some more information.

    Is this in a single folder, or a tree of folders?
    Do you want "abc & def.jpg" to become "1,456,213.jpg" ?

    Night



      Greenhorn

      • Experience: Experienced
      • OS: Windows 7
      Re: How to rename the file with file size
      « Reply #2 on: November 29, 2013, 05:33:54 AM »
      Pleas help me with the command for renameing the file using file size (note: i want to skip the 0KB file).

      If I understood you correctly, this is what you're looking for. This will rename all the files that are larger than 0 bytes.

      for /R %t in (*.*) do if %~zt neq 0 ren "%t" new.*
      pause


      Or using a batch file:

      @echo off
      for /R %%t in (*.*) do if %%~zt neq 0 ren "%%t" new.*
      echo.
      echo.
      echo   Done!
      pause


      /R switch is only necessary if you need to do this recursively. Of course, you can change the renaming to something other than "new", and the extension type instead of all extensions.
      « Last Edit: November 29, 2013, 05:46:46 AM by Night »

      itkesavan

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Windows XP
        Re: How to rename the file with file size
        « Reply #3 on: November 29, 2013, 09:47:43 AM »
        got the logic. files are there in same folder. help in the below with proper code please using the file name and folder name where i have to give what

        file available at d:\test folder,  filename abc*.txt (total 2 file) in this one will be 0KB.

        Please help with batch script

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Re: How to rename the file with file size
        « Reply #4 on: November 29, 2013, 11:06:43 AM »
        Sure smells like homework to me...
        " 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 #5 on: November 29, 2013, 02:43:18 PM »
          not home work needs to do it where i have similar problem where need to do daily...

          itkesavan

            Topic Starter


            Rookie

            • Experience: Beginner
            • OS: Windows XP
            Re: How to rename the file with file size
            « Reply #6 on: November 30, 2013, 08:35:43 AM »
            any help on this need it urgently... pls

            foxidrive



              Specialist
            • Thanked: 268
            • Experience: Experienced
            • OS: Windows 8
            Re: How to rename the file with file size
            « Reply #7 on: December 01, 2013, 05:15:58 AM »
            I asked a question on how you want the files named (and Night has provided you with an almost complete solution - it needs the filename format implemented).

            Your description is not clear.

            itkesavan

              Topic Starter


              Rookie

              • Experience: Beginner
              • OS: Windows XP
              Re: How to rename the file with file size
              « Reply #8 on: December 01, 2013, 06:05:46 AM »
              I got what night has said but i dont know where to give the folder location and file name

              just tell you what i want

              I have file in D:\test folder, inside this folder there are soo meny files, from that i have to rename abc*.txt (total 2 file) in this one file will be 0KB. so the script needs to skip the 0kb file and rename only the file which has data. hope now you got my request. please help me with clear batch script because the script which night has given in that i dont know where to give floder location and file name.

              Thanks in advance

              foxidrive



                Specialist
              • Thanked: 268
              • Experience: Experienced
              • OS: Windows 8
              Re: How to rename the file with file size
              « Reply #9 on: December 01, 2013, 06:17:28 AM »
              .

              itkesavan

                Topic Starter


                Rookie

                • Experience: Beginner
                • OS: Windows XP
                Re: How to rename the file with file size
                « Reply #10 on: December 01, 2013, 10:19:51 AM »
                not got reply

                Geek-9pm


                  Mastermind
                • Geek After Dark
                • Thanked: 1026
                  • Gekk9pm bnlog
                • Certifications: List
                • Computer: Specs
                • Experience: Expert
                • OS: Windows 10
                Re: How to rename the file with file size
                « Reply #11 on: December 01, 2013, 10:27:11 AM »
                A big part of solving a problem is being able to describe how a solution would be found. That is way in the old school you would make a sketch of a logical sires of steps that would define the solution. After having made a concise logical outline. the coding becomes easy.

                itkesavan

                  Topic Starter


                  Rookie

                  • Experience: Beginner
                  • OS: Windows XP
                  Re: How to rename the file with file size
                  « Reply #12 on: December 01, 2013, 10:32:35 AM »
                  I m a starter on batch script just learning. needs this urgently....

                  Lemonilla



                    Apprentice

                  • "Too sweet"
                  • Thanked: 70
                  • Computer: Specs
                  • Experience: Experienced
                  • OS: Windows 7
                  Re: How to rename the file with file size
                  « Reply #13 on: December 01, 2013, 03:15:01 PM »
                  I m a starter on batch script just learning. needs this urgently....
                  I don't think you are reading the replies.  If you look at different command's help menus you should be able to figure this out.  To see the help menus you need to type the command (Most listed in the 'help' command) with a "/?" following.  You will want to look up 'for','if','ren','dir'.  I have full faith in your ability to read and comprehend these commands.  I wish you luck, but know that the members of this forum do not read minds and cannot understand what you want without you asking.

                  Quote from: patio
                  God Bless the DOS Helpers...
                  Quote
                  If it compiles, send the files.

                  foxidrive



                    Specialist
                  • Thanked: 268
                  • Experience: Experienced
                  • OS: Windows 8
                  Re: How to rename the file with file size
                  « Reply #14 on: December 01, 2013, 10:23:18 PM »
                  This command line based on Night's code should work.

                  for %t in (d:\temp\abc*.txt) do if %~zt neq 0 ren "%t" "new name%~xt"

                  Please provide a good explanation in future and people might be more inclined to help.
                  If you look at your subject line and first post it looks like you want to rename filenames with the filesize.