Sample Header Ad - 728x90

7zip archive multiple files with their respective names

0 votes
2 answers
2079 views
I have lots of files that I want to archive/compress using 7zip utility. They all reside in the same folder. Each archive must have the same name as the file that is to be archived. For example, if the files are 1.txt, 2.txt, 3.txt then the archives should be 1.7z, 2.7z and so on. I have found some batch scripts, but I need a bash script. I can list all the files using
for i in *.txt; do echo $i; done
but cannot make it work with 7zip command, i.e. 7z a 'archive.7z' 'file.txt'
Asked by heikrana (141 rep)
Aug 17, 2022, 04:27 PM
Last activity: Nov 28, 2024, 06:05 PM