Jump to content

Unpacking with 7z messes up permissions for resulting files.


Go to solution Solved by BRiT,

Recommended Posts

Currently using 6.11.5. 

 

I have thousands of compressed files, .zip and .7z, and I was trying to unpack them into their own folders but had a hell of a time trying to figure out how since I am not familiar with linux and all of that.

 

What I ended up doing that worked was navigating to the folder with Krusader and opening the terminal "here" and running this command:

 

for file in *.7z; do
7z x -o"${file%.7z}" "$file"
done

 

It unpacks the files into their own separate folders which is perfect, but then I can't access the folders via my windows share. It tells me that I don't have the permission to touch the file. Now I fixed this by running the new permissions tool for that specific share, but my question is, is there something different I can do that would do the same thing but without messing up my permissions?

 

I figured out how to do the same with the zip files by running this command:

for file in *.zip; do
unzip -d"${file%.zip}" "$file"
done

 

 however the resulting files do not have any permission issues, they just work.

 

This isn't a major issue but just a QoL sort of thing that would be helpful because I still have a few more thousand files to go with this project. 

 

Link to comment
  • Solution

The 7z file format does NOT store file permissions. You will always need to use a post process script to set permissions to what you want them to be.

 

You may be able to adjust the behavior somewhat by setting "umask".

 

From Wiki:

Quote

The 7z format does not store filesystem permissions (such as UNIX owner/group permissions or NTFS ACLs), and hence can be inappropriate for backup/archival purposes.

A workaround on UNIX-like systems for this is to convert data to a tar bitstream before compressing with 7z. But it is worth noting that GNU tar (common in many UNIX environments) can also compress with the LZMA2 algorithm ("xz") natively, without the use of 7z, using the "-J" switch. The resulting file extension is ".tar.xz" or ".txz" and not ".tar.7z". This method of compression has been adopted with many distributions for packaging, such as Arch, Debian (deb), Fedora (rpm) and Slackware. (The older "lzma" format is less efficient.)[8] On the other hand, it is important to note, that tar does not save the filesystem encoding, which means that tar compressed filenames can become unreadable if decompressed on a different computer..

 

 

 

Edited by BRiT
Link to comment
21 minutes ago, BRiT said:

The 7z file format does NOT store file permissions. You will always need to use a post process script to set permissions to what you want them to be.

 

You may be able to adjust the behavior somewhat by setting "umask".

 

From Wiki:

 

 

 

This is good to know! Thank you very much. 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...