Thread: file renaming

Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Ok, my script works a little differently but gets the output you need. What do you mean he wants both renames? As in the first rename replaces Slide1.jpg (etc) and then the second rename is a copy?

    Mark.
    programming language development: www.netytan.com Hula

  2. #17
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    10
    Rep Power
    0
    I want to stick with copy. Copy first Slide1.jpg to s00.jpg to s00L.jpg
  4. #18
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0
    http://www.python.org/doc/current/li...le-shutil.html

    would be helpful for making a copy of a file
  6. #19
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    A slitly reworked, more flexable version of my previous script which instead or renaming the files makes a copy.. you end up with 3 sets, Slidex.jpg, s0x.jpg and s0xx.jpg

    It's virtually identical to the last with os.rename() replaced with shutil.copyfile() and a new vairable 'starts' which holds the start string of the files your targeting i.e. 'Slides' and a few other little changes

    Mark.
    Attached Files
    programming language development: www.netytan.com Hula

  8. #20
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    10
    Rep Power
    0
    quick question, How do you write a counter that counts 01, 02, 03 ...10, 11 not 1,2,3,4,5,6,7...10,11
  10. #21
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    325
    Rep Power
    12
    dunno if there's another way, but this works

    def pad(input):
      input = str(input)
      if len(input) == 1:
        input = "0"+input
      return input
    Last edited by lazy_yogi; October 17th, 2003 at 03:36 AM.
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    133
    Rep Power
    12
    Partly ironic:
    Code:
    def counter():
      i = 0
      while True:
        yield "%02d" % (i+1,)
        i += 1
    
    >>>count = counter()
    >>>for i in range(3):
    ...  count.next()
    ...
    '01'
    '02'
    '03'
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo