我使用ProcessBuilder将exiftool的输出打印到一个文件中。我正在尝试对一个.opus文件exiftool Aero.opus > Aero.txt运行这个命令。这在终端上运行得很好,但在processbuilder中,它似乎在解析它时遇到了麻烦。
这是它的一个简单的程序。请注意,该目录设置为/home/sarah,并且Aero.opus文件存在于该目录中。
还要注意的是,输出会打印到控制台,而不是应该打印到文件中,并且它不能识别>操作符。
@Test
public void testExifprocess() throws IOException {
//File Located at /home/sarah/Aero.opus
ProcessBuilder builder = new ProcessBuilder("exiftool", "Aero.opus", ">", "Aero.txt").directory(Paths.get("/home/sarah").toFile())
.inheritIO();
builder.start();
}下面是输出:
Running com.protonmail.sarahszabo.stellaropusconverter.tests.StellarDiskManagerTest
File not found: >
File not found: Aero.txt
======== Aero.opus
ExifTool Version Number : 10.80
File Name : Aero.opus
Directory : .
File Size : 13 MB
File Modification Date/Time : 2018:06:29 19:19:08-04:00
File Access Date/Time : 2018:07:16 23:20:27-04:00
File Inode Change Date/Time : 2018:07:16 23:20:27-04:00
File Permissions : rw-rw-r--
File Type : OPUS
File Type Extension : opus
MIME Type : audio/ogg
Opus Version : 1
Audio Channels : 2
Sample Rate : 48000
Output Gain : 1
Vendor : Lavf58.17.100
Title : Aero
Artist : Daniel Deluxe
Picture Type : Front Cover
Picture MIME Type : image/png
Picture Description : Daniel Deluxe -- Aero.png
Picture Width : 1280
Picture Height : 720
Picture Bits Per Pixel : 0
Picture Indexed Colors : 0
Picture Length : 946992
Picture : (Binary data 946992 bytes, use -b option to extract)
1 image files read
2 files could not be read
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0主文件夹:

我的操作系统是Kubuntu18.04,带有Java 8_171。
https://stackoverflow.com/questions/51372871
复制相似问题