Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old October 16th, 2003, 10:12 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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


Reply With Quote
  #17  
Old October 16th, 2003, 10:19 AM
eddiembabaali eddiembabaali is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 10 eddiembabaali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I want to stick with copy. Copy first Slide1.jpg to s00.jpg to s00L.jpg

Reply With Quote
  #18  
Old October 16th, 2003, 10:49 AM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
http://www.python.org/doc/current/l...ule-shutil.html

would be helpful for making a copy of a file

Reply With Quote
  #19  
Old October 16th, 2003, 04:36 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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
File Type: py recopy.py (787 Bytes, 250 views)

Reply With Quote
  #20  
Old October 16th, 2003, 10:02 PM
eddiembabaali eddiembabaali is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2001
Posts: 10 eddiembabaali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
  #21  
Old October 17th, 2003, 03:32 AM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 6
dunno if there's another way, but this works

def pad(input):
&nbsp;&nbsp;input = str(input)
&nbsp;&nbsp;if len(input) == 1:
&nbsp;&nbsp;&nbsp;&nbsp;input = "0"+input
&nbsp;&nbsp;return input

Last edited by lazy_yogi : October 17th, 2003 at 03:36 AM.

Reply With Quote
  #22  
Old October 17th, 2003, 03:54 AM
percivall percivall is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 133 percivall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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'

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > file renaming


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT