file-date-organizer
Advanced tools
Comparing version 0.7.4 to 0.8.0
@@ -108,4 +108,25 @@ { | ||
] | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "CLI 06 - Created", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"program": "${workspaceFolder}/src/command.js", | ||
"args": [ | ||
"--source", | ||
"/Users/flackey/pCloud Drive/Automatic Upload/", | ||
"--target", | ||
"/Volumes/MPHD01/Multimedia/Photos/", | ||
"--move", | ||
"--use-name", | ||
"--use-created", | ||
"--recursive", | ||
"--console", | ||
"--overwrite" | ||
] | ||
} | ||
] | ||
} |
{ | ||
"name": "file-date-organizer", | ||
"version": "0.7.4", | ||
"version": "0.8.0", | ||
"description": "Move files into a folder structure organized by date.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -51,3 +51,4 @@ # File Date Organizer for NodeJS | ||
| `console` | Log activity to console | `boolean` | `false` | | ||
| `limit` | Number of files to process | | `` | | ||
| `limit` | Number of files to process | `number` | | | ||
| `allowFuture` | Allow file names with date in future | `boolean` | `false` | | ||
@@ -54,0 +55,0 @@ ### Contact |
@@ -62,3 +62,4 @@ # File Date Organizer for NodeJS | ||
| `console` | Log activity to console | `boolean` | `false` | | ||
| `limit` | Number of files to process | | `` | | ||
| `limit` | Number of files to process | `number` | | | ||
| `allow-future` | Allow file names with date in future | `boolean` | `false` | | ||
@@ -65,0 +66,0 @@ ### Contact |
@@ -28,3 +28,4 @@ const os = require('os'); | ||
limit : { type: 'number', default: '', name: 'Number of files to process' }, | ||
limit : { type: 'number', default: -1, name: 'Number of files to process' }, | ||
allowFuture : { type: 'boolean', default: false, name: 'Allow file names with date in future' }, | ||
}; |
@@ -19,2 +19,4 @@ const _ = require('../../utils'); | ||
type = '`boolean`'; | ||
} else if (def[key].type === 'number') { | ||
type = '`number`'; | ||
} else if (def[key].isPath) { | ||
@@ -32,2 +34,5 @@ type = '`string (path)`'; | ||
break; | ||
case 'number': | ||
defValue = (def[key].default >= 0) ? `${def[key].default}` : ''; | ||
break; | ||
case 'string': | ||
@@ -34,0 +39,0 @@ defValue = `\`${def[key].default}\``; |
@@ -20,6 +20,9 @@ const path = require('path'); | ||
if (!opts.useName) { return null; } | ||
const info = uglyDate.analyze(path.basename(source)); | ||
const info = uglyDate.analyze(path.parse(source).name); | ||
if (!info || !info.date || !info.hasDate) { | ||
return null; | ||
} | ||
if (!opts.allowFuture && info.date > (new Date())) { | ||
return null; | ||
} | ||
if (!info.hasTime && opts.addHour) { | ||
@@ -26,0 +29,0 @@ return null; |
@@ -18,3 +18,3 @@ const _ = require('../utils'); | ||
if (_.isNumber(opts.limit) && _.isNumber(opts.count) && Number(opts.limit) > 0 && Number(opts.count) >= Number(opts.limit)) { | ||
if (opts.limit > 0 && opts.count >= opts.limit) { | ||
if (!limitReached) { | ||
@@ -38,3 +38,3 @@ toConsole(opts, `File limit reached ${opts.limit}. Stopping...`); | ||
file.error = 'Original file not cleaned up.'; | ||
toConsole(opts, ` ${file.error}`); | ||
toConsole(opts, ` - ${file.error}`); | ||
} else { | ||
@@ -51,3 +51,3 @@ toConsole(opts, ' Exists... ignoring (cleaned up source file).'); | ||
file.error = 'Overwrite not allowed'; | ||
toConsole(opts, ` ${file.error}`); | ||
toConsole(opts, ` - ${file.error}`); | ||
return; | ||
@@ -58,3 +58,3 @@ } | ||
file.error = 'Cannot create directory.'; | ||
toConsole(opts, ` ${file.error}`); | ||
toConsole(opts, ` - ${file.error}`); | ||
return; | ||
@@ -69,3 +69,3 @@ } | ||
file.error = exists ? 'File not overwritten.' : 'File not copied.'; | ||
toConsole(opts, ` ${file.error}`); | ||
toConsole(opts, ` - ${file.error}`); | ||
return; | ||
@@ -82,14 +82,14 @@ } else { | ||
if (opts.move !== true) { | ||
toConsole(opts, ` Time: ${_.getDuration(file.start, file.copied)}`); | ||
return; | ||
if (opts.move === true) { | ||
if (!_.deleteFile(file.source)) { | ||
file.error = 'Original file not deleted.'; | ||
toConsole(opts, ` - ${file.error}`); | ||
return; | ||
} else { | ||
file.deleted = new Date(); | ||
} | ||
} | ||
if (!_.deleteFile(file.source)) { | ||
file.error = 'Original file not deleted.'; | ||
toConsole(opts, ` ${file.error}`); | ||
} else { | ||
file.deleted = new Date(); | ||
toConsole(opts, ` Time: ${_.getDuration(file.start, file.deleted)}`); | ||
} | ||
const end = opts.move ? file.deleted : file.copied; | ||
toConsole(opts, ` Time: ${_.getDuration(file.start, end)}`); | ||
}); | ||
@@ -96,0 +96,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61521
1359
71