這可能是一個虛擬問題,但我無法弄清楚它爲什麼不起作用。比方說,我打開一個終端/家庭/ romu /音樂節/阿萊恩·巴什/編譯文件夾中運行以下命令:使用NodeJs處理文件系統的新手問題
AtomicParsley "01. J'écume.m4a" --artwork ../../cover.jpg
結果是:
Started writing to temp file.
Progress: ======================================================> 99% -|
Finished writing to temp file.
所以它的工作原理。現在,我希望自動有點這個過程中,我正在寫一個劇本的NodeJS,那就是:
// ES6 only
'use strict';
// Get rid off the first 2 elements of the arguments array,
// First is the path of the node enfine itself
// second is the path of this script
let args = process.argv.slice(2);
// hard coded, will always be those values
let root = "/home/romu/Musique";
let ci = "../../cover.jpg";
let artist = args[0];
let album = args[1];
// Album path
let tracks_path = `${root}/${artist}/${album}`;
const spawn = require('child_process').spawn;
let ap = spawn('pwd', [], { cwd: tracks_path });
ap.stdout.on('data', (data) => {
console.log(`Location: ${data}`);
});
ap = spawn('AtomicParsley', [`"01. J'écume.m4a" --artwork ../../cover.jpg`], { cwd: tracks_path });
ap.stdout.on('data', (data) => {
console.log(`OUT: ${data}`);
});
ap.stderr.on('data', (data) => {
console.log(`ERR: ${data}`);
});
ap.on('close', (code) => {
console.log(`CODE: ${code}`);
});
我得到以下輸出:
Location: /home/romu/Musique/Alain Bashung/Compilation
ERR: AtomicParsley error: can't open "01. J'écume.m4a" --artwork ../../cover.jpg for reading: No such file or directory
OUT: AP error trying to fopen "01. J'écume.m4a" --artwork ../../cover.jpg: No such file or directory
CODE: 1
我不知道什麼是繼續,爲什麼它不工作。任何幫助都會很棒。謝謝。
節點進程是否在同一個編譯目錄中運行? –