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:
  #1  
Old November 27th, 2004, 10:46 PM
ivanhope ivanhope is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 35 ivanhope User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 59 m 4 sec
Reputation Power: 5
need somebody to help me create a script

the thing is like this:
i have 90 folders, each one with a couple of files inside

i want a script that put all the files in one folder, but i want to add to each file the folder name to the file name.

for example i have "Adams, Douglas" folder with files "book 1" book 2" book 3"
and i want to get "Adams, Douglas - book 1" , "Adams, Douglas - book 2" "Adams, Douglas - book ..."

i dont know how to manage files with python so thats why i didnt made anything

thanks for your help

Reply With Quote
  #2  
Old November 28th, 2004, 08:58 PM
deltacoder's Avatar
deltacoder deltacoder is offline
slightly insane code guru
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2004
Location: Indianapolis, IN
Posts: 871 deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level)deltacoder User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 h 8 m 36 sec
Reputation Power: 12
Send a message via AIM to deltacoder Send a message via MSN to deltacoder
http://python.org/doc/2.3.4/lib/os-file-dir.html
__________________

deltacoder.com :: W3C Standards :: PHP.net :: Google

Reply With Quote
  #3  
Old December 5th, 2004, 01:55 AM
weam weam is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 73 weam User rank is Private First Class (20 - 50 Reputation Level)weam User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 23 h 52 m 46 sec
Reputation Power: 5
#you know there's nothing like a standard way of doing this, but I would create a script like the following (Recursive)

from dircache import listdir
def Write(Dir,Name,Destination="AnyFolder/"):
f=open(Dir+Name,'rb')
Data=f.read()
f.close()
Dir = Dir.replace("/","-")
f=open(Destination + Dir + Name,'wb')
f.write(Data)
f.close()
def DeepCopy(Dir,Destination="AnyFolder/"):
DirVar = listdir(Dir)
for i in DirVar:
try:
listdir(i)
DeepCopy(Dir+i+"/")
except:
Write(Dir,i)
Directory="foo/"
DeepCopy(Directory)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > need somebody to help me create a script


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 2 hosted by Hostway
Stay green...Green IT