Giter VIP home page Giter VIP logo

quokka's Introduction

quokka: an interactive file renamer

quokka is an interactive file renamer, which helps to rename multiple files in a systematic manner.

It provides a set of rules:

  • to change letter case (#case)
  • to delete characters at a specified position (#delete)
  • to change file extensions (#extension)
  • to insert a text into a specified position (#insert)
  • to remove a text (#remove)
  • to replace a text (#replace)
  • to serialize file names (#serialize)
  • to strip a set of characters off (#strip) and
  • to import lines of a file for insertion (#import)

with options for fine control. You can combine these rules as you want by adding them into the rule chain. Editing each rule and the rule chain is performed interactively as you do in a shell prompt. The following, for example, shows how to rename files' extensions to .node using quokka:

running quokka

where > indicates a quokka's prompt and #extension before it shows the user is editing the #extension rule. Typing help lists what commands quokka accepts in general and in a specific rule mode. (In fact, quokka displays characters in color for better readability.)

Even if its source code contains some stuff related to MS Windows, it currently supports and is tested only for Unix-like environments. For now, nothing is guaranteed for MS Windows.

INSTALL.md explains how to build and install the program. For the copyright issues, see the accompanying LICENSE.md file.

Among libraries used, alphanum.js has been modified to meet quokka's needs; it has been modified to behave in a more similar way to ls -v and to return the sorted array instead of nothing. If you need to replace that module with, say, a updated one, it is necessary to apply these changes properly.

Usage Tips

A few useful tips follow below.

  1. Sort files in a natural order

The -v option makes quokka behave in the same way as ls -v when sorting file names; it affects how numbers in file names are handled. Without the option, quokka performs lexicographic comparison which puts, say, img10 before img2 because 1 has a smaller code than 2 has. This looks natural to most (if not all) programmers, but ordinary users would like to place 10 after 2, which the -v option does.

  1. Control the sorting order

quokka can accept file names to rename from an external file given through the -f option. For example, you can edit the file obtained from redirection of ls -t -1 (where -t for sorting by modification time and -1 for displaying only file names) and give it to quokka with the -f option.

  1. One-line multiple-command

quokka is designed to accept multiple commands in a line. For example, you can change files' extensions to docx by this one-line input:

   > #extension change to docx done rename

instead of these multiple lines:

   > #extension
   #extension> change to docx
   #extension> done
   > rename

The thing is that the newline character does not differ from other white-spaces in separating commands.

  1. Names with embedded spaces

The earlier versions of quokka used quotation for spaces embedded in file names. This approach made troubles with readline's auto-completion supported by node.js, and had me choose to escape spaces with a leading backslash. Since the backslash character is now used for escaping spaces, it is necessary to escape backslashes themselves. For example,

   #replace> replace \  .

makes quokka replace a space with a period (note the space after \), and

   #strip> strip \\

does quokka strip off all instances of \. In most cases, the smart auto-completion explained below helps you not to forget escaping spaces.

  1. Smart auto-completion

The recent versions of quokka support the smart auto-completion that is smart in the sense that it is aware of the input context and suggests appropriate words. For example, pressing a tab key after HDTV when quokka expects arguments for the replace command shows every partial string starting with HDTV in file names to rename. This helps you to avoid annoying use of your mouse to copy characters from your terminal screen.

If you have a question or suggestion, do not hesitate to contact me via email (woong.jun at gmail.com) or web (http://code.woong.org/).

quokka's People

Contributors

mycoboco avatar

Stargazers

Branden Dane avatar

Watchers

James Cloos avatar  avatar

quokka's Issues

possible problems from import command need to be considered

The import command reads lines from an external file to insert into file names, which might lead to problematic cases that require special handling like:

  • arbitrary byte sequence inserted into file names
  • white-spaces not correctly in the current version (handling them consistently is filed as another ticket)

add FAQs

Necessary to add FAQs document.

one-line explanation for commands would be helpful

Because there are no extra explanations for supported commands (rule modes), users are not easy to figure out what job a certain command performs unless they enter that mode; for example, what is the difference of 'delete' than 'remove'?

separate "extension" from quokka.js

To aid introduction of new features to quokka, it is necessary to separate functions that implement features from the main code, quokka.js.

improve the import command

It would be useful for imported lines to be parsed with a field separator like a tab before inserted into file names, which is easy to implement.

handle spaces in a consistent way

Even if all kinds of spaces distinguish commands from their arguments or other commands, escaping with backslashes applies only to a normal space, for example, when constructing a list for auto-completion. This should be fixed so that all white-spaces have to be dealt with in a consistent way.

refactor code

  • apply new coding style
  • change directory structure

smart auto-completion needed

The current auto-completion for quokka always lists up commands available even when arguments for a command (strings from file names in most cases) are requested.

It would be more useful if proper candidates show up depending on user input.

-n option needs to override -v option

When a user run quokka with the -v option by an alias set or a shell script as specified in INSTALL.md, it becames impossible to keep the original order of file names with the -n option because -n is active only when there is no -v.

remove multiple appearances of command names

In code for each command, there are multiple appearances of a command name, which requires cumbersome replacement because a new command is more easily implemented by copying and modifying an existing one.

By introducing a variable to contain command names, that would be simpler.

improve FAQs

FAQs need to deal with smart auto-completion, escaped spaces and one-line multi-commands.

implement "describe" feature

As rules have complicated features, users may need to see what the net effect of their rule before applying it with the `done' command.

modifications to libraries should be moved out of node_modules

To publish the project to npm, all modifications to the libraries need to be moved out of node_modules.

  1. the none property added to colors.js may be able to be implemented with no touch on the file.
  2. since alphanum.js is not a npm module, it should be kept in lib/ not in node_modules/.

run quokka on a huge list of names

quokka has been tested only on a moderately large list of file names to rename and needs to be tested on a larger one for both performance and convenience.

fix bug related to running command

#delete> #delete from position 20 until end

/home/mycoboco/script/quokka/src/quokka.js:733
            cset.cmd(t.cmd).func(t.param);
                            ^
TypeError: Cannot call method 'func' of undefined

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.