0
bzip2.exe -z compressfolder/*.*

How should modify it so that it will do its job to sub-folders of compressfolder?

ilhan
  • 8,700
  • 35
  • 117
  • 201

2 Answers2

1

You'd better to use "find" utility, however I'm not shure it is available on windows under posix environment.

However:

find compressfolder -type f -print0 | xargs -0 -n 1 bzip2 -z

This command on any *nix system will find each regular file under "compressfolder", and will run "bzip2 -z" for each of the files. If you are using cygwin or mingw (as I suppose), it should work on windows also.

quarck
  • 21
  • 2
  • `find` works fine on Windows, too. It might have a different syntax from the command found on a UNIX-based system, but it's still there. No installation of CygWin required. – Cody Gray - on strike Apr 17 '11 at 08:09
  • @Cody: The `find` that's included in Windows is more akin to `grep`. – Joey Apr 17 '11 at 09:49
  • it did not work. also I've tried this one find compressfolder -type f -print0 | xargs -0 -n 1 bzip2 -z. Even it did not not compressed the files under compressfolder. – ilhan Apr 17 '11 at 18:36
  • On windows to get this code working, you should also have "xargs" utility, I don't sure you have it. – quarck Apr 21 '11 at 13:26
1

This will compress every file under compressfolder, recursively:

for /r .\compressfolder %%a IN (*.*) do bzip2 -z %%a

The for /r will recurse into each subfolder of .\compressfolder. %%a holds each file specified by *.*, and the part following do runs bzip2 on each file. The above examples assumes you'll run this from the parent folder to the compressfolder. Place the line in a batch file, eg. bzip2all.bat and run it.

Vik David
  • 3,640
  • 4
  • 21
  • 29