Created
February 23, 2013 19:58
-
-
Save suisho/5021096 to your computer and use it in GitHub Desktop.
windowsが対象パスが長すぎますとか言ってきてにっちもさっちもいかなくなったときにフォルダ名を一文字に変えてやるスクリプト。
npm install glob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var glob = require("glob"); | |
var fs = require("fs"); | |
var path = require("path") | |
glob("./LONG_FILE_NAME/**/",function(err, files){ | |
files.reverse().forEach(function(f){ | |
var newFsp = f.split("/") | |
newFsp.pop() | |
newFsp.pop() | |
newFsp.push("a") | |
var newF = newFsp.join("/")+"/"; | |
console.log(f,"=>",newF); | |
try{ | |
var stat = fs.statSync(f); | |
if(!stat.isDirectory()){ | |
return; | |
} | |
fs.renameSync(f,newF) | |
}catch(e){ | |
console.log(e); | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment