# list archive files with password protection?



## kr651129 (Sep 12, 2013)

I just did a data recovery of some old storage devices. It gave me *a lot* of stuff. Is there any way to find and list only the archives that are password protected?


----------



## ShelLuser (Sep 12, 2013)

kr651129 said:
			
		

> Is there anyway to find and list only the archives that are password protected?


That would heavily depend on both the archiver and optionally the way you encrypted the files.

But sure, generally speaking this should be doable. For example you could try to open the archive (listing it's contents for example) and when it's password protected this operation should trigger an error and associated exit code. Then you could anticipate on that by adding the current filename to a list.

Should also be easily scriptable, for example something in the likes of `for a in *; do <open archive> || echo "$a is encrypted >> archive_list"; done`.

(edit:)

What this basically does is go over all the files in the current directory, then it could try to open the archive (since I don't know the archiver being used I can't create an example). The || entry indicates that the following command will only be executed if the previous command sends out an exit code other than 0 (which means that something went wrong).

So if the exit code is something other than 0 it will output a string where $a will be substituted by the name of the file which is currently being processed, this string gets added to a file called archive_list (the adding to is set up by using the >> characters).

And finally the done keyword marks the end of the loop (the so called "for loop").


----------

