Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Option to ignore file extension and detect archive format by file content #255

Closed
yene opened this issue Oct 20, 2020 · 4 comments
Closed

Comments

@yene
Copy link

yene commented Oct 20, 2020

What would you like to have changed?

An option to ignore the file extension and detect the archive format based on the file content.

Why is this feature a useful, necessary, and/or important addition to this project?

Some of our customers deliver file formats with wrong extensions.

What alternatives are there, or what are you doing in the meantime to work around the lack of this feature?

No idea. Maybe a bash file -I to check the type.

@coolaj86
Copy link
Collaborator

coolaj86 commented Oct 24, 2020

There's now a --ext option which you can use set set the type explicitly, as per #252, released with v3.4.0.

I don't think that we're going to do any type of sniffing on files, but you could do something like this, if it's a script environment:

arc -ext rar unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz
arc -ext tar unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz
arc -ext tar.bz2 unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz
arc -ext tar.gz unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz
arc -ext tar.xz unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz
arc -ext zip unarchive ~/Downloads/bat-v0.15.4-x86_64-apple-darwin.tar.gz

@coolaj86
Copy link
Collaborator

You could also use file to help determine the file type by "magic headers":

file /tmp/evil/double-evil.rar
/tmp/evil/double-evil.rar: POSIX tar archive

@coolaj86
Copy link
Collaborator

@yene Are the proposed workarounds sufficient to close the issue?

@mholt
Copy link
Owner

mholt commented Jan 2, 2022

This has been implemented for all formats in #302, which will become v4 soon. Please give it a try and let me know your thoughts!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants