Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compress multiple files? #32

Open
asthagarg2428 opened this issue Mar 23, 2022 · 1 comment
Open

How to compress multiple files? #32

asthagarg2428 opened this issue Mar 23, 2022 · 1 comment

Comments

@asthagarg2428
Copy link

How to compress multiple files?

@jackyhieu1211-hn
Copy link

jackyhieu1211-hn commented Apr 24, 2022

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()
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants