I'm trying to run a command line tool and taking the result. I checked it in terminal:
/usr/bin/exiftool -filename -directory -createdate -model "/Users/dirk/Desktop\" -t -S -q -r -f >"RenamerOutfile0.txt"
This runs fine and delivers result in file. Using SWIFT I tried this:
let task = NSTask()
task.launchPath = "/usr/bin/exiftool"
task.arguments = ["-filename -directory -createdate -model \"/Users/dirk/Desktop\" -t -S -q -r -f"]
let pipe = NSPipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
Unfortunatly nothing happens. data is assigned 0 byte - no result. If I insert the redirection to file no file is created. Any idea what's the difference in calling the tool from terminal than with this task?
task.arguments = ["-filename", "-directory", "-createdate", "-model", "\"/Users/dirk/Desktop\"", "-t", "-S", "-q", "-r", "-f"]
– Peter71 Jun 11 '15 at 07:41later on I want to use let output: String = NSString(data: data, encoding: NSUTF8StringEncoding)!.stringByAppendingString("") but data is still 0 bytes long.