Skip to content

Instantly share code, notes, and snippets.

@suisho
Created February 23, 2013 19:58
Show Gist options
  • Save suisho/5021096 to your computer and use it in GitHub Desktop.
Save suisho/5021096 to your computer and use it in GitHub Desktop.
windowsが対象パスが長すぎますとか言ってきてにっちもさっちもいかなくなったときにフォルダ名を一文字に変えてやるスクリプト。 npm install glob
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