Monday, 11 December 2017

7 zip - How do I archive with subdirectories using the 7-Zip command line? Or, how do I KEEP the folder structure while archiving?

I have a bunch of files like this:


C:\G\G1\35antique-shop.mp3
C:\G\G2\35antique-shop.mp3
C:\G\G1\09saguri.mp3
C:\G\G2\09saguri.mp3

I just want to know how to keep the folder structure while archiving. This is more important than the duplicate thing, to know how to solve that, would be a bonus.



@Lamb "Do you want to archive only selective files (not the whole folder content) from the G1 and G2 folders?"



That almost says it all, but I'll try to improve: Not only do I want to move only some selected files to an archive. I also have a list of these files, including path-names to each file.


So, in SubDir1 there might be 10 files, of which I want to zip three, and in SubDir1\sub2 there might be five files, of which I want to zip all five. The files that I need to archive are in a listfile.


There might be duplicate files, so my hope is that with subdirectories added, 7-Zip does NOT see them as duplicates.


And I like to do it on the command line.


I've tried a batch file like this:


7z a -r MyArchive.7z C:\G\G1\35antique-shop.mp3
7z a -r MyArchive.7z C:\G\G2\35antique-shop.mp3
7z a -r MyArchive.7z C:\G\G1\09saguri.mp3
7z a -r MyArchive.7z C:\G\G2\09saguri.mp3

This also means that files 01antique-shop.mp3, 02antique-shop.mp3, ...., til 33antique-shop.mp3 and 34antique-shop.mp3, should NOT be archived.


The foldernames (=subdirectories) weren't added to MyArchive.7z, and this is the problem.


Obviously, I'd like to use just one commando with a listfile, but that doesn't work either.


I've tried:


7z a -mx0 -tzip C:\$$-edrive\F-G-H.zip @fgh.txt

which actually works pretty fine as far as the selecting goes, but it does NOT keep the directory structure. Sadly.


How do I do this?

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...