Skip to content

Commit

Permalink
Trim output file name (unless --notrim)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Hotmann committed Jun 13, 2017
1 parent 72df4ae commit 4aaac56
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The new file name does not need to contain a file extension. If you do not speci
```-s```, ```--sim```: Simulate rename and just print new file names
```-n```, ```--noindex```: Do not append an index when renaming multiple files. Use with caution.
```-v```, ```--verbose```: Print all rename operations completed. Prints the same information as the -s option but goes through with the renames.
```--notrim```: Do not trim whitespace at beginning or end of ouput file name
```-h```, ```--help```: Show help

### Variables
Expand Down
3 changes: 3 additions & 0 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ const argv = yargs
alias: 'verbose',
boolean: true,
describe: 'Print all rename operations completed'
}, 'notrim': {
boolean: true,
describe: 'Do not trim whitespace at beginning or end of ouput file name'
}
})
.help('help')
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ module.exports = {
fileObj.newName = fileObj.newName + replacements.i.function(fileObj, '1');
}

// TRIM output file name unless --notrim option used
if (!args.notrim) {
fileObj.newName = fileObj.newName.trim();
}

let operationText = fileObj.base + ' → ' + fileObj.newName + fileObj.newNameExt;

if (args.s) { // SIMULATED if argument --s just print what the output would be
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rename-cli",
"version": "2.3.0",
"version": "2.4.0",
"description": "A command line utility for renaming files",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 4aaac56

Please sign in to comment.