Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@azu
Created July 4, 2010 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/463430 to your computer and use it in GitHub Desktop.
Save azu/463430 to your computer and use it in GitHub Desktop.
D&Dしたディレクトリ以下をフラットにする #NILScript
// ==UserScript==
// @name flat_dir
// @namespace http://efcl.info/
// @description D&Dしたディレクトリ以下をフラットにする。
// @author azu
// @homepage http://efcl.info/
// @twitter https://twitter.com/azu_re
// ==/UserScript==
/*
フォルダ(1)内のフォルダ(2)の中身をフォルダ(1)に移動させて、フォルダ(2)を削除
フォルダ
├fileA
├fileB
└フォルダ[DIR]
├fileC
└fileD
フォルダ
├fileA
├fileB
├fileC
└fileD
になる
*/
var arg = Main.arguments[2]; // 引数
if (arg) {
for (var i = 2, l = Main.arguments.length; i < l; i++) {
var dir = new Directory(Main.arguments[i]);
if (dir.exists) {
var d = null;
for (d in dir.children) {
// alert(d.name +" "+ d.attributes.directory);
if (d.attributes.directory) { // dir.attributes.directoryでフォルダならtrue
var d_1 = null;
for (d_1 in d.children) { // d_1 はフォルダのフォルダ
// var d_1=new File(d_1); 必要ない
d_1.move(dir);
}
// ファイルを移動し終わったらdelete
d.remove();
}
}
} else {
continue;
// println(dir.path+" is not exist");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment