Skip to content

TarFile / ZipFile - option to overwrite files when extracting new ones #105339

Open
@Guy-Markman

Description

@Guy-Markman

Feature or enhancement

This is a discussion about a feature I have, before I try to implement it.

I would be glad if there was an option to overwrite old files when extracting new files with the same name at the same location.

It can be a new parameter, which will be defaulted to False, which if true, will check if there is a file / directory with the same path. If it doesn't have, it will delete the existing file /directory before writing the new ones.

Pitch

I'm writing a program which is extracting a archive to a location the user want me to extract it.
When extracting with CLI tools, if there is a file that will have the same path as existing file, I will get a prompt which will ask me if I want to replace the old file with the new one.

But I'm Python I have to check if there is a file with the same path of the file I'm going to extract, otherwise I will get a file exists exception.

Why not make it built in?

Also, by adding it as an optional Parameter, we won't break backwards compatibility.

Previous discussion

https://discuss.python.org/t/overwrite-existing-files-when-extracting-a-file/27311

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions