【发布时间】:2010-06-28 07:50:02
【问题描述】:
我需要从程序执行命令。命令行没问题,我在终端试了下,在程序里不行。
我从我的代码中添加一个副本:
File dir = new File("videos");
String[] children = dir.list();
if (children == null) {
// Either dir does not exist or is not a directory
System.out.print("No existe el directorio\n");
} else {
for (int i=0; i<children.length; i++) {
// Get filename of file or directory
String filename = children[i];
//Recojo el momento exacto
System.out.print("\n" +filename);
Process p = Runtime.getRuntime().exec("exiftool -a -u -g1 -j videos/"+filename+">metadata/"+filename+".json");
}
程序必须获取文件夹中所有文件的名称(文件名)并提取这些视频的元数据,将它们写入文件夹“元数据”中的 .json 文件中。
问题出在哪里?
【问题讨论】:
-
顺便说一句 - 避免说“它不起作用”。这并没有给任何人任何继续下去的信息(尽管在这种情况下它成功了)。相反,您应该给出让您认为有问题的输出/错误消息。如有必要,您还应该说明您预计会发生什么,以及实际会发生什么(突出它们的不同之处)。
标签: java process runtime.exec io-redirection