File Interactions

Reply

Join Date: Jul 2005
Posts: 68
Reputation: danizzil14 is an unknown quantity at this point 
Solved Threads: 1
danizzil14's Avatar
danizzil14 danizzil14 is offline Offline
Junior Poster in Training

File Interactions

 
0
  #1
Nov 6th, 2005
Ok I was wondering if anyone could help me with how to make a python program interact with files. Copying, pasting, moving, things like that, opening. If it cant really be discussed quicky are there any good tutorials? Mainly a organinzing python program.(looks for a certain file extention, then moves it to a desegnated folder)

Advice and help grately apprecated :cheesy:
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,858
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 867
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: File Interactions

 
0
  #2
Nov 7th, 2005
The module shutil has copy(from, to) and move(from, to) for your file operations.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 68
Reputation: danizzil14 is an unknown quantity at this point 
Solved Threads: 1
danizzil14's Avatar
danizzil14 danizzil14 is offline Offline
Junior Poster in Training

Re: File Interactions

 
0
  #3
Nov 8th, 2005
Uh..... *drools*

Sorry but i am a noob with this and the only things I've made was a Hello World Program and a specilzied calcultor that does caluclations for the popular internet game Runescape.
Blender is by far the best free 3D computer Graphics program and it is expandable with python! GoTo www.blender3d.org
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,858
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 867
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: File Interactions

 
0
  #4
Nov 9th, 2005
Here is a code snippet of a typical file copy ...
[php]# copy a file to another folder or to another filename
# copy2() retains original date/time, copy() does not

import shutil

# make sure folder and file exists
sourcefile = "D:/Python24/Atest/Audi.jpg"

# destination-folder has to exist
destinationfile = "C:/Temp/Audi.jpg"

try:
shutil.copy2(sourcefile, destinationfile)
except IOError:
print "File or folder does not exist!"
else:
print "File successfully copied!"
[/php]
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC