Announcement

Collapse
No announcement yet.

How can I batch truncate/rename file names?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I batch truncate/rename file names?

    Say I have a directly of 5 files, named as follows:
    1234-123.jpg
    2345-13.jpg
    3456.jpg
    5678 M.jpg
    4567_3.jpg
    I'd like to batch rename them by truncating after the fourth character and then adding the file extension:
    1234.jpg
    2345.jpg
    3456.jpg
    5678.jpg
    4567.jpg
    Is there some free utility that can do this for me?
    Bronson Design Studio, LLC
    Website: bronsondesign.com
    Facebook: facebook.com/bronsondesign

    #2
    Re: How can I batch truncate/rename file names?

    Not free, but if you had Filemaker Pro at hand or maybe even excel -
    create a "calculation" to get the left 4 characters and then concatenate the results with ".jpg"

    In Excel -
    Code:
    CONCATENATE((LEFT(A1,4)),".jpg")
    Oops files not names, hmmm
    On the Mac anyway it will do file name changes by the batch built in - not sure if it will do the GET off hand
    Last edited by Barrett; 12-02-08, 07:58 PM.
    Thanks,
    -Barrett
    Favorite Host Hostasaurus.com
    Order Processing by Shipworks.com
    Kindly Suggesting to:
    *Dump Explorer and http://GetFireFox.com
    *Post a meaningful subject line.
    *Click the # button before pasting code

    Comment


      #3
      Re: How can I batch truncate/rename file names?

      Originally posted by Barrett View Post
      Not free, but if you had Filemaker Pro at hand or maybe even excel -
      create a "calculation" to get the left 4 characters and then concatenate the results with ".jpg"
      I know how to do those operations in excel, but how does that help me rename files in a directory?
      Bronson Design Studio, LLC
      Website: bronsondesign.com
      Facebook: facebook.com/bronsondesign

      Comment


        #4
        Re: How can I batch truncate/rename file names?

        Maybe this site has something

        http://www.snapfiles.com/Freeware/sy...ilerename.html
        Thanks,
        -Barrett
        Favorite Host Hostasaurus.com
        Order Processing by Shipworks.com
        Kindly Suggesting to:
        *Dump Explorer and http://GetFireFox.com
        *Post a meaningful subject line.
        *Click the # button before pasting code

        Comment


          #5
          Re: How can I batch truncate/rename file names?

          Thanks...I'll take a look.
          I tried something from download.com a few months back, but was over complicated for what seems like a trival task.
          Bronson Design Studio, LLC
          Website: bronsondesign.com
          Facebook: facebook.com/bronsondesign

          Comment


            #6
            Re: How can I batch truncate/rename file names?

            This might do it for the Mac users

            http://www.publicspace.net/ABetterFinderRename/

            Just tested this and it works great.
            Use the truncate function for the task specified in thread.
            Last edited by Barrett; 12-02-08, 08:33 PM.
            Thanks,
            -Barrett
            Favorite Host Hostasaurus.com
            Order Processing by Shipworks.com
            Kindly Suggesting to:
            *Dump Explorer and http://GetFireFox.com
            *Post a meaningful subject line.
            *Click the # button before pasting code

            Comment


              #7
              Re: How can I batch truncate/rename file names?

              Originally posted by Barrett View Post

              OMG, the ReNamer program is amazingly simple to use and lighting fast. Thanks Barrett!
              Bronson Design Studio, LLC
              Website: bronsondesign.com
              Facebook: facebook.com/bronsondesign

              Comment


                #8
                Re: How can I batch truncate/rename file names?

                I use 1-4a Rename (Superb Batch Renamer) and I really like it. It has more of an explorer interface than ReNamer which I like more, but the renaming doesn't look as powerful.

                Comment


                  #9
                  Re: How can I batch truncate/rename file names?

                  Geez.. I know I"m going to show my age here (or longevity in geekdom)

                  Are you on a windows machine? well, linux or mac either doesn't matter.
                  You don't have to buy or get any software.. your pc will do it already.
                  You just need to use the command prompt and drop into dos.

                  If you don't know how... click on start, then in the (on vista) search box type
                  cmd.exe

                  this will pop up a black window.

                  now us old geeks remember what the command DIR and CD do.

                  CD means change directory
                  dir means show me the files in this directory

                  Change directories to get to the folder you need to rename things in.

                  (fyi.. you might want to make a copy of that folder in case you screw up).

                  now...
                  while you are in that folder.
                  you can rename using the RENAME command.

                  if you need help type
                  RENAME /?
                  it will give you an example..

                  Here is the 'magic' part.. you can use wildcards.
                  ? means one character
                  * means any number of characters in a row

                  to play with it safely try out the wildcards with the DIR command
                  DIR
                  DIR *.jpg
                  DIR ?.jpg
                  DIR ??????.jpg
                  for the ? type searches you might not get any results if you do not have
                  a nameed file that followed that pattern. try this to see what happens
                  DIR *.??g
                  should show you anything that ends with . 2 characters and a g

                  you can use these wildcards on rename too.
                  If you put a ? in a slot in the first name..
                  and in the second name it won't change that slot if you put a ? there too.
                  And if you leave out, you can effectively remove a character from a filename.

                  simple single file renaming goes like this
                  rename myfile2kkk.jpg myfile2k.jpg

                  But using wildcards you can batch rename a bunch of files too.
                  you can shorten and insert characters.
                  It's very powerful

                  For example: say I have the files named setup(2).exe and setup(3).exe

                  rename setup(?).exe setup(?k).exe

                  results in setup(2k).exe and setup(3k).exe

                  remember the ? represents a slot such as 3rd character, it isn't a variable that will hold a value, so you can't use it to shift things around.

                  But if you want to truncate a whole bunch of files to 4 characters and an extension. It's fast, it's easy, and you already have it.


                  psst.. be careful that you won't result in duplicates filenames because if it will, the following renames will over write the earlier rename.

                  If you have used naming conventions and only want to rename files that have a specific pattern in them
                  then you can do somethine really wild like

                  rename ????ly*.exe ????.exe

                  will take any file starting with 4 characters, then the letters ly, then any number of characters followed by .exe
                  and rename it to the first 4 characters followed by .exe

                  It won't rename any files that do not have 4 characters, an ly and a .exe on the end.

                  anyway.. hope this ramble helps.

                  You might want to google "DOS rename" or "DOS rename command"

                  for more examples.

                  Comment


                    #10
                    Re: How can I batch truncate/rename file names?

                    fyi.. I do this on my MAC too since it is possible to use a terminal window.
                    On a mac instead of dir the directory command is ls (I suppose for list)
                    and the rename command itself is a different word since it's a linux environment.
                    On a mac you'd use the
                    mv
                    command to rename files this way.

                    Comment


                      #11
                      Re: How can I batch truncate/rename file names?

                      On Mac no need of the terminal there are already Apple Scripts pre-installed for this... on the menu bar on top right, but in my opinion nothing beat the flexibility and the features of A Better Finder Rename

                      Comment


                        #12
                        Re: How can I batch truncate/rename file names?

                        If you are still looking for a program to do the file renaming, I use a free program called Bulk Rename Utility. It has tons of options to file renaming, and it is very easy to use.
                        Unemployed

                        Comment


                          #13
                          Re: How can I batch truncate/rename file names?

                          Say I have a directly of 5 files, named as follows:
                          1234-123.jpg
                          2345-13.jpg
                          3456.jpg
                          5678 M.jpg
                          4567_3.jpg
                          I'd like to batch rename them by truncating after the fourth character and then adding the file extension:
                          1234.jpg
                          2345.jpg
                          3456.jpg
                          5678.jpg
                          4567.jpg
                          Is there some free utility that can do this for me?
                          Yes. The following script in biterscripting (free, http://www.biterscripting.com ) . I am making this script verbose by adding comments (in bold) so you can modify as necessary.


                          # Get a list of all files "*" in "directory".
                          # Change directory to correct one.
                          var str list ; lf -n "*" "directory" > $list
                          while ($list <> "")
                          do
                          # Get the next file in the list
                          var str file ; lex "1" $list > $file
                          # Get the file name only. It is after the last (l) slash (/).
                          var str name ; stex -p "^/^l[" $file > $name
                          # Get the extension. It is after the last dot (.).
                          var str extn ; stex "[^.^l" $name > $extn
                          # Shorten $name to 4 chars. Remove all chars after 4th char.
                          chex "4[" $name > null
                          # Create the new name. It is name (now has up to 4 chars) plus extn.
                          var str new_name ; set $new_name = $name+$extn
                          # Rename file. File names/paths may contain spaces, so use double quotes.
                          system rename ("\""+$file+"\"") ("\""+$new_name+"\"")
                          done
                          Sen

                          Comment


                            #14
                            Re: How can I batch truncate/rename file names?

                            You can batch truncate/rename file names through KrojamSoft BatchRenameFiles program.

                            Comment


                              #15
                              Re: How can I batch truncate/rename file names?

                              You can use the command line and not have to buy any program. Works on PC, mac or Linux.
                              Are you 100% sure your first four characters are unique? If not you will lose some
                              due to being overwritten.

                              Comment

                              Working...
                              X