Skip to content

Instantly share code, notes, and snippets.

@S--Minecraft
Created November 21, 2015 13:38
Show Gist options
  • Save S--Minecraft/fec47764edd660156e38 to your computer and use it in GitHub Desktop.
Save S--Minecraft/fec47764edd660156e38 to your computer and use it in GitHub Desktop.
フォルダの下の一階層を消す
###
- desc
A - B - C
- D - E
- F - G
となってるのが
A - C
- E
- G
になる
- usage
coffee folder.coffee #{その下の一階層が消されるフォルダ} #{出力先}
###
fs = require "fs-extra"
path = require "path"
error = (err) ->
if err?
console.log "Error: #{err}"
return
removeOneDir = (folderPath) ->
fs.readdir(folderPath, (err, list) ->
error()
for folder in list
folderPath2 = path.join(folderPath, folder)
dest = path.join(process.argv[3], folder)
fs.copy(folderPath2, dest, (err) ->
error()
console.log "Copyed: #{folderPath}"
)
)
return
fs.readdir(process.argv[2], (err, list) ->
error()
for folder in list
folderPath = path.join(process.argv[2], folder)
console.log "Loading: #{folderPath}"
if fs.statSync(folderPath).isDirectory()
removeOneDir(folderPath)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment