Re: [Tutor] copy files selectively from source to destination

2016-12-06 Thread Peter Otten
anatta anatta wrote: > Here is my working code - to copy files from one drive to another. > > I however want to copy selective files. > > For example I like to copy only .txt files only from the source to > destination, and not other types of files. > > How could I do this selective copying? S

Re: [Tutor] copy files selectively from source to destination

2016-12-05 Thread Emile van Sebille
On 12/05/2016 08:20 AM, anatta anatta wrote: Dear tutor! Here is my working code - to copy files from one drive to another. I however want to copy selective files. For example I like to copy only .txt files only from the source to destination, and not other types of files. How could I do t

Re: [Tutor] copy files selectively from source to destination

2016-12-05 Thread Alan Gauld via Tutor
On 05/12/16 16:20, anatta anatta wrote: > I however want to copy selective files. > For example I like to copy only .txt files only > How could I do this selective copying? By applying an if test just before you copy filetype = '.txt' # or read it as an input ... if sourcefile extension =

[Tutor] copy files selectively from source to destination

2016-12-05 Thread anatta anatta
Dear tutor! Here is my working code - to copy files from one drive to another. I however want to copy selective files. For example I like to copy only .txt files only from the source to destination, and not other types of files. How could I do this selective copying? Thanks in advance for t

Re: [Tutor] copy files + directory tree via ftp

2007-09-26 Thread Kent Johnson
Nelson Kusuma wrote: > Hello > > I have a problem when copy files and directory tree in > ftp, scripts in here only copy one file: To transfer an entire directory with ftplib you will have to read the local directory with os.listdir() and loop to send the files. There are a few higher-level mod

[Tutor] copy files + directory tree via ftp

2007-09-26 Thread Nelson Kusuma
Hello I have a problem when copy files and directory tree in ftp, scripts in here only copy one file: from ftplib import FTP rootList = [] session = FTP() session.connect('workstation', port=21) session.login(user='saiki', passwd='saiki') session.retrlines('LIST', rootList.append) f=open('D:/PARAM

Re: [Tutor] Copy files

2006-02-06 Thread David Holland
Alan,Thanks for that.  I had the wrong file names, now it works, in case anyone is interested here is the code.  I use it because at work I need to change different versions of sqlnet.ora :-def compare_files(file_name1, file_name2):     x = filecmp.cmp (file_name1, file_name2)     print

Re: [Tutor] Copy files

2006-01-31 Thread Alan Gauld
> The only problem is that despite the fact that as the same user, > I can manually change these files (so I must have the right file > permissions ?) Can you do it from within python at the >>> prompt Use os.getcwd() to find out where you are Use os.chdir() to navigate Use os.listdir() to li

Re: [Tutor] Copy files

2006-01-31 Thread David Holland
Alan,Thanks for that.  Hopefully this now is easier to read. The only problem is that despite the fact that as the same user, I can manually change these files (so I must have the right file permissions ?) - the copying does not happening.def compare_files(file_name1, file_name2):    

Re: [Tutor] Copy files

2006-01-30 Thread Alan Gauld
David, Can I suggest you rethink your variable names? That might make it clearer what is happening. > def compare_files(file_name1, file_name2): > x = cmp (file_name1, file_name2) > return x Seems fair enough except file_name1 and file_name2 are actually file *contents*! And in fact

[Tutor] Copy files

2006-01-30 Thread David Holland
I wrote a small program that compares files test1 and test2 to test3. If the files are different  then it  copies either test1 to test3 or the reverse.The problem is that the although the shutil.copy2 in thefunction change_files  works without error it does not copy.  Can anyone see what is