I have a code to archive a ZIP file into another ZIP file, using command like this:
String rootftp = "C:\\ROOT_DIR_PUSHFILE\\";
String tampungString = "AAA\\PFILE\\AAA20140531.zip";
String password = "testing";
String command = "cmd.exe "
+ "/C"
+ " cd C:\\Program Files\\WinRAR \n"
+" && rar a -n "+rootftp.trim()+tampungString+".zip"+" "+ rootftp.trim()+tampungString + " -p"+password.trim();
System.out.println(command);
File file = new File(rootftp.trim()+tampungString);
try {
Runtime.getRuntime().exec(command);
file.delete();
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
But the result is :
When I try to archive a specific file, the results is always archive from root directory, not just the specific file, like AAA20140531.zip file, can you explain, why? And how to fix it?
Use this command to create
.rar
without parent folder:-ep1
switch makes the result to exclude the base folder from the paths,