0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nexeでexeにドラッグアンドドロップされたファイル・フォルダを取得する

Last updated at Posted at 2018-12-01

#始めに
nexeでパッケージしたexeにドラックアンドドロップされたファイル・フォルダのパスを受け取って色々したいなーと思って調べました。

#実装
普通にnode.jsのコマンドライン引数を使えば良さそうです。

const fs = require('fs');

const ddfilelist = process.argv.slice(0,process.argv.length); //argvをコピーする
ddfilelist.splice(0,2); //3番目以降がコマンドライン引数なのでその部分だけ取得

ddfilelist.forEach((item) => {
  const type = fs.statSync(item).isDirectory() ? "directory" : "file";  //directoryかfileか判定
  console.log(`${item} : ${type}`);
})
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?