Find the answer to your Linux question:
Results 1 to 2 of 2
Hey guys, Im new enough the korn scripting so don't really know where to start on this one! Basically I have a list of files in one directory eg. 2011-05-12-1700_ABCD.xml ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    1

    Korn script to change part of file name


    Hey guys,
    Im new enough the korn scripting so don't really know where to start on this one!

    Basically I have a list of files in one directory
    eg.

    2011-05-12-1700_ABCD.xml
    2011-05-12-1700_EFGH.xml
    2011-05-12-1700_IJKL.xml
    2011-05-12-1700_MNOP.xml
    2011-05-12-1700_QRST.xml

    What I want to do is write a script that will change the first part of the filename and leave the second part alone.

    So Basically i want to change "2011-05-12-1700" to "2011-05-13-0900"
    So after the script is run I will have

    2011-05-13-0900_ABCD.xml
    2011-05-13-0900_EFGH.xml
    2011-05-13-0900_IJKL.xml
    2011-05-13-0900_MNOP.xml
    2011-05-13-0900_QRST.xml

    Any ideas???

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    11,159
    That's what the rename command is for. IE:
    Code:
    rename 2011-05-13-1700 2011-05-13-0900 2011-05-13-1700*.xml
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •