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

Discussion in 'Python' started by Ben Kial, Sep 29, 2003.

  1. Ben Kial

    Ben Kial Guest

    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
     
    Ben Kial, Sep 29, 2003
    #1
    1. Advertising

  2. 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.
     
    Andrew Bennetts, Sep 29, 2003
    #2
    1. Advertising

  3. Ben Kial

    Miki Tebeka Guest

    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/lib/module-shutil.html

    HTH.
    Miki
     
    Miki Tebeka, Sep 29, 2003
    #3
  4. Ben Kial

    Neil Hodgson Guest

    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
     
    Neil Hodgson, Sep 29, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kaeli
    Replies:
    8
    Views:
    1,418
    Harald Kirsch
    Feb 13, 2004
  2. Alex
    Replies:
    2
    Views:
    1,287
  3. **--> That Guy Downstairs
    Replies:
    14
    Views:
    748
    S7Solutions
    Feb 21, 2006
  4. Replies:
    26
    Views:
    2,175
    Roland Pibinger
    Sep 1, 2006
  5. scad
    Replies:
    4
    Views:
    978
    James Kanze
    May 28, 2009
Loading...

Share This Page