1

for example I have one folder which contains below mentioned files:

001.txt
001.doc
002.txt
002.doc
003.txt
003.doc
Continue....

I want all similar file names each in separate zip. e.g.

001.zip Contains (001.txt, 001.doc)
002.zip Contains (002.txt, 002.doc)
003.zip Contains (003.txt, 003.doc)

and similarly all files are zipped separately

I am using winrar & 7zip to zip the files.

1
  • This sounds like a scenario for Powershell.
    – Bort
    Jun 1, 2016 at 13:59

2 Answers 2

0

Create a new directory "001" Move 001.txt and 001.doc in this directory and then compress "001"

4
  • 1
    What if there were 20,000 files? The solution doesn't scale well
    – Joe Taylor
    Jun 1, 2016 at 12:32
  • Correct, but the initial question was not about scaling :) Jun 1, 2016 at 12:36
  • The line; Continue.... at the bottom suggests that there are a lot more than juts the one's he's included as an example.
    – Joe Taylor
    Jun 1, 2016 at 12:59
  • Hassan, your solution is perfect. 1 up vote for it. Sorry but I could not give it as 15 reputation is required for up vote. Jun 1, 2016 at 15:27
0

If using Linux OS:
1. create a file.sh.
2. copy these commands in the file. (set your last_number)
3. execute in terminal: sh file.sh

#!/bin/bash
last_number=<set_your_number>
for i in $(seq 1 $last_number)
    do
        find . -iname "*$i.*" | awk -F / '{print $2}' | tar -cf $i.tar -T -
    done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .