AndroidP7zip icon indicating copy to clipboard operation
AndroidP7zip copied to clipboard

How to compress multiple files?

Open asthagarg2428 opened this issue 3 years ago • 1 comments

How to compress multiple files?

asthagarg2428 avatar Mar 23 '22 08:03 asthagarg2428

This is command.

P7ZipApi.executeCommand(Command.getCompressCmd(list, outPath, type)) == ExitCode.EXIT_OK

type: String = "zip"

fun getCompressCmd(
        fileInfos: List<FileSelectedEntity>,
        outPath: String,
        type: String
    ): String? {
        val filePaths: ArrayList<String> = ArrayList()
        for (i in fileInfos.indices) {
            filePaths.add(fileInfos[i].path)
        }
        return getCompressCmd(filePaths, outPath, type)
    }

    fun getCompressCmd(filePaths: ArrayList<String>, outPath: String, type: String): String {
        val command = StringBuilder(String.format("7z a -t%s '%s'", type, outPath))
        for (i in 0 until filePaths.size) {
            command.append(" '").append(filePaths[i]).append("'")
        }
        return command.toString()
    }

jackyhieu1211-hn avatar Apr 24 '22 05:04 jackyhieu1211-hn