473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

write a file "copy" program in Python for Unix and Windows...

I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

Any help will be very much appreciated. Thanks in advance.
Ben
Jul 18 '05 #1
3 5634
On Mon, Sep 29, 2003 at 01:59:52AM +0000, Ben Kial wrote:
I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

Any help will be very much appreciated. Thanks in advance.


Try shutil.copy2 (and/or other functions in the shutil module).

-Andrew.
Jul 18 '05 #2
Hello Ben,
I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

http://www.python.org/doc/current/li...le-shutil.html

HTH.
Miki
Jul 18 '05 #3
Ben Kial:
I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).


The platform copy utilities know more than you want to about file
attributes including Read-only, Hidden, Archive, and System bits, compressed
and encrypted attributes, access control lists, multiple forks and further
esoterica. It probably even has a reasonable idea what to do when the
destination file system is different to the source and so may not, for
example, be able to use Unicode file names or ACLs. On Windows, you could
start with something like

os.system("xcopy /K /X /I c:\\os\\s4\\win32 g:\\xxx")

Another approach is to use the native SHFileOperation API although this
is not wrapped by the Win32 extensions. You could use ctypes to access it.

Neil
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tony George | last post by:
Hi, I'm having a problem using the Copy module on a ClearCase view that's been set as "readonly" (i.e. ct chview -readonly <view tag>). I want to copy a file out of this view and put it in...
1
by: John Finch | last post by:
We are running SQL 7 on a Windows NT Server. If you copy a 25Mb file from this machine to a W2K server, the file copy takes over 5 minutes on a 100Mpbs switched network. Copying the same file to...
0
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now,...
4
by: adnan boz | last post by:
Hi All, Does somebody know why File.Copy function is 10 times slower than standard windows drag and drop copy between folders, when I copy files over the network? Actually, I need to copy files...
2
by: Pete Davis | last post by:
I'm getting an exception when trying to copy a file. I basically do a File.Copy(source, dest, false); source is the source full path and filename. dest is the destination full path and...
6
by: RitaG | last post by:
Hello. I have a VB.Net program that copies a file from one server to another server. This program has been working without any problems for about a year. A couple of weeks ago the "server from"...
1
by: Dan | last post by:
I have an application that I want to use for copying files. My goal is to copy a files, if a file is in use or not accessible because of security reasons I want to make note of that file then...
5
by: Saabster | last post by:
Hi all, It's always the simple stuff that trips you up I guess. Here is the issue I'm dealing with. I have a folder with 1400 excel files that I need to move to another location. Since each...
3
by: =?Utf-8?B?R2FuZXNoYQ==?= | last post by:
Hi I would like to use File.Copy with UNC paths. I have seen this problem reported by others as well. Can i use File.Copy with UNC paths. ie., i would like to copy a file from one of the folder to...
5
by: Johnny Jörgensen | last post by:
Using File.Copy in the System.IO namespace, it's easy to copy one or more files. But I wonder: Is it possible to get windows to display its File Copy Progress dialog at the same time - or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.