|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
http://python.org/doc/2.3.4/lib/os-file-dir.html
|
|
#3
|
|||
|
|||
|
#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:Directory="foo/"try:listdir(i)DeepCopy(Dir+i+"/")except:Write(Dir,i) DeepCopy(Directory) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > need somebody to help me create a script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|