| | |
how to copy a file
![]() |
•
•
Join Date: Mar 2007
Posts: 110
Reputation:
Solved Threads: 31
Create a list of file names that match your criteria:
Python Syntax (Toggle Plain Text)
import os path_name = 'your_directory' key = 'journal' nameList = [os.path.join(path_name, n) for n in os.listdir(path_name) \ if os.path.isfile(os.path.join(path_name, n)) and n.startswith(key)]
•
•
Join Date: Apr 2006
Posts: 148
Reputation:
Solved Threads: 40
•
•
•
•
Hi,
I'm trying to copy a file in python, I have imported the shutil module
My problem is that I want to copy file in a directory beginning with a certain name. Example I have 5 file in the fodler but i want to copy all the one tat begin with journal.something How could i do that
thanks
Python Syntax (Toggle Plain Text)
import shutil,glob,os os.chdir("wherefileis") for FILE in glob.glob("journal*"): shutil.copy(FILE, "someotherdir")
![]() |
Similar Threads
- Copy file with a name change (ASP)
- Cannot copy file: Data error (cylcic redundancy check) (Windows NT / 2000 / XP)
- how to copy a file from one machine to another using beans? (Java)
- copy a file (Python)
- Cannot copy file: Data error (cylcic redundancy check) (Windows NT / 2000 / XP)
- Windows XP Pro install on new machine "could not copy file .." (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: Programmatically Select item in TreeCtrl
- Next Thread: prime no
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui heads homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython





