Code Monkey home page Code Monkey logo

file-renamer's Introduction

File Renamer

Rename Multiple Files in a Folder

This was inspired by, and is based on a gist by Scriptex, index.js. I have modified it to suit my purpose.
I have been downloading books from Zlibrary 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 IDE: Before

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 Files: After

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.

file-renamer's People

Contributors

dependabot[bot] avatar scriptex avatar wesscoby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

file-renamer's Issues

More Authors

When a book has 4 or more authors, the naming should simply be: first author et al

Modularize the code

Break the code into modules to enable easy extension of the functionality.
For instance, the main functionality, for now, is renaming zlibrary-downloaded books accoding to the patterns specified. This can be extended, having several patterns for files to be renamed, and their corresponding handlers to perform the renaming.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.