Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wesscoby/file-renamer
Rename Multiple Files in a Folder. This can be tweaked several ways
https://github.com/wesscoby/file-renamer
Last synced: about 1 month ago
JSON representation
Rename Multiple Files in a Folder. This can be tweaked several ways
- Host: GitHub
- URL: https://github.com/wesscoby/file-renamer
- Owner: wesscoby
- Created: 2019-04-15T08:11:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T19:59:54.000Z (almost 2 years ago)
- Last Synced: 2023-03-02T22:12:11.204Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.14 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## File Renamer
#### Rename Multiple Files in a FolderThis was inspired by, and is based on a gist by [Scriptex](https://github.com/scriptex), [index.js](https://gist.github.com/scriptex/20536d8cda36221f91d69a6bd4a528b3).
I have modified it to suit my purpose.
I have been downloading books from [Zlibrary](https://b-ok.cc/) and the downloaded files have a naming format:
##### \[Author\(s\)\]File_name\(z-lib.org\).extension
###### Eg. \[WessCoby\]_Rename_Multiple_Files_in_a_Folder(z-lib.org\).pdf![Files: Before](./images/files_bfr.png)
![IDE: Before](./images/ide_bfr.png)The Key things i want from this file name string are just the file name and authors(s)
And i want to rename each file to:
##### Filename - Author(s).extension
###### Eg. Rename Multiple Files in a Folder - WessCoby.pdf## Renaming Process
* Use `filePattern` to filter for files that need to be renamed
* Use `authorPattern` to extract Author name(s), and assign to the variable `author` and remove underscores
* Use `bookNamePattern` to extract book name and assign to the variable `book` and remove underscores
* Combine `book` and `author` and assign to `newName`.
* Format: `book - @author.extension`![IDE: After](./images/files_aftr.png)
![Files: After](./images/ide_aftr.png)## Usage
* Create a new folder named `Files` in the root directory and place the files to be renamed in it.
* In the index file, create your pattern (with a rename method)
* There are two ways to use the pattern:
* First call `RenameFiles.usePattern(patternClass)`. Then `RenameFiles.exec()`
* Second, `RenameFiles.exec({ usePattern: patternClass })`
NB: `RenameFiles.exec()` returns a Promise:
`RenameFiles.exec({ usePattern: patternClass }).then( console.log ).catch( console.error );`
* Then use either `npm start`, `node index` or `node .` to run.