Last active
April 13, 2020 09:26
-
-
Save netalkGB/b413e966bae9b1a30f9ede58270c4e55 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
| const path = require('path') | |
| const fs = require('fs') | |
| const fsPromsises = fs.promises | |
| const crypto = require('crypto') | |
| const mdxoTmpDir = 'C:\\Users\\alex\\Desktop\\20170519_mdxwin260\\NetCache213\\Music' | |
| const destDir = 'C:\\Users\\alex\\Desktop\\files' | |
| const md5Sums = new Set() | |
| const md5hex = function(buffer){ | |
| const md5hash = crypto.createHash('md5') | |
| md5hash.update(buffer, 'binary') | |
| return md5hash.digest('hex') | |
| } | |
| fs.watch(mdxoTmpDir, async (et, fname) => { | |
| if(et === 'rename') { | |
| return | |
| } | |
| try { | |
| const fpath = path.join(mdxoTmpDir,fname) | |
| const ext = fname.split('.')[fname.split('.').length - 1] | |
| const buffer = await fsPromsises.readFile(fpath) | |
| const md5sum = md5hex(buffer) | |
| console.log(fpath) | |
| // console.log("eventType", et); | |
| console.log("filename:", fname) | |
| console.log("extension:", ext) | |
| console.log(md5sum) | |
| const destFname = `${Date.now()}.${ext}` | |
| const destPath = path.join(destDir, destFname) | |
| if(!md5Sums.has(md5sum)) { | |
| md5Sums.add(md5sum) | |
| console.log(`COPY: ${fpath} => ${destPath}`) | |
| await fsPromsises.copyFile(fpath,destPath) | |
| console.log(`DONE: ${fpath} => ${destPath}`) | |
| } else { | |
| console.log(`SKIP: ${fpath} => ${destPath}`) | |
| } | |
| } catch(e) { | |
| console.warn(e) | |
| } | |
| }) | |
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
| # (AD)PCMは手動でコピーしてね | |
| $flist = (Get-Content C:\Users\gb\Desktop\notitle.mpp |Select-String "FullPath"|foreach {$_.toString().split("\")[$_.toString().split("\").Length - 1]}) | |
| $flist2 = (Get-ChildItem C:\Users\gb\Desktop\files|Sort-Object LastWriteTime|ForEach-Object { $_.Name }) | |
| for($i = 0; $i -lt $flist.Length; $i++) { | |
| Move-Item ("C:\Users\gb\Desktop\files\" + $flist2[$i]) ("C:\Users\gb\Desktop\files\" + $flist[$i]) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment