Created
November 21, 2015 13:38
-
-
Save S--Minecraft/fec47764edd660156e38 to your computer and use it in GitHub Desktop.
フォルダの下の一階層を消す
This file contains hidden or 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
### | |
- 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