GithubHelp home page GithubHelp logo

cli-caseswitcher's Introduction

Command line version of CaseSwitcher

CaseSwitcher let's you change filenames to either UPPERCASE or lowercase. It takes a directory and changes the filename of its content to the case you specify.

This is the use case from CaseSwitcher

Consider the situation where you (using a UNIX system - Linux/Mac) and a friend on a Windows system sends you an project to work on. You open the folder and you realize that all the files are in uppercase or title case. However, within the code, all files were referenced in lowercase. This is not a problem on Windows with Windows being case-insensitive with file names. This can however be problematic because the UNIX file system is case sensitive. This will mean that you will have to carefully change the file names to lowercase for your system. In such a situation, CaseSwitcher is your best friend.

How is this better than the rename utility on UNIX

With the rename utility you are forced to come up with a regular expression which can be unintuitive and daunting if you are not familiar with regular expressions. CaseSwitcher, I believe is more intuitive; all you need to do is just supply the path to the directory and the case you want to rename the files to.

Admittedly, the downside with CaseSwitcher is that you are forced to install PHP. This means CaseSwitcher is not portable. Users without PHP or those who "hate" PHP cannot use it. But have no worries, there are plans to create a shell script to provide this same intuitive functionality.

Requirements

You must have at least PHP Version: 7.0.25+ installed on your system

How to install (UNIX)

CaseSwitcher is just a single PHP file called caseswitcher. You will need to do the following:

  1. Download this repo and extract the file.

    Let's assume that you have downloaded and extracted the file into a directory called Download located here /home/nana/Download

  2. Make the file executable

    To make the file executable, open your terminal and navigate to where you have extracted the file to like this: cd /home/nana/Download

    Now type this to make the file executable: sudo chmod +x caseswitcher

    Enter your password if prompted

  3. Now copy and place this file in a folder that is in your path

    Read the following if you have no idea what your path is and how to carry out this third step:

    Knowing your path

    Your path is just a 'list' of directories your operating system searches to find commands anytime you type a command on the terminal. This list shows directories separated by a colon : If you want to know which folders are in your path just type echo $PATH on your terminal. You should see something similar to this: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    This path is showing 7 directories separated by a colon :

    We can list the directories as follows:

    1. /usr/local/sbin
    2. /usr/local/bin
    3. /usr/sbin
    4. /usr/bin
    5. /sbin
    6. /bin
    7. /usr/games

    This means that anytime you type a command on your terminal the operating system will look through these directories to find the command. If the command is not found in any of the directories in your path, the system tells you that the command was not found.

    Back to CaseSwitcher

    To use CaseSwitcher just copy it from where you have it extracted to and place it in any of the folders you see in your path. You will need administrative rights to most of the directories in your path.

    Let's assume you want to place it inside the /usr/local/bin directory and you have extracted CaseSwitcher to /home/nana/Download. Open your terminal and type the following command sudo cp /home/nana/Download/caseswitcher /usr/local/bin/. That's all! You now have CaseSwitcher in your path. You can now go ahead to use it.

  4. That's it. Just launch your terminal and start using CaseSwitcher

How to use

Just open your terminal, call CaseSwitcher, supply the directory you want to change and the case you want to switch to. Just make sure the directory is writable.

Like this:

Say you want to change the contents of /home/nana/project to either lowercase or uppercase, just type:

caseswitcher -d /home/nana/project -l or caseswitcher -d /home/nana/project -u

This means change the contents of the project directory to lowercase or to uppercase.

If you want CaseSwitcher to recursively go through all sub-folders and change the filenames, then provide the -r option like this: caseswitcher -d /home/nana/project -l -r

This means go through all sub-folders and change the filenames to lowercase.

You can join the options together without the need to separate them. Just make sure the -d is the last one you specify. This is because anytime caseswitcher sees the -d option, it expects what ever follows next to be a path to a directory.

eg. caseswitcher -lrd /path/to/directory.

This is exactly the same as caseswitcher -d /path/to/directory -l -r

NOTE: You cannot use both the -l and -u options together. That will not make sense.

Options explained

Option Meaning Example
-d [DIRECTORY] Directory. This option is required and expects an argument
You supply the path to the directory whose contents you want to rename. The directory must exist, not empty and must be writable.
caseswitcher -d path/to/directory
-l Lowercase. This option instructs caseswitcher to change all filenames to lowercase. You cannot use this option together with -u option. caseswitcher -d path/to/directory -l
-u Uppercase. This option instructs caseswitcher to change all filenames to uppercase. You cannot use this option together with -l option. caseswitcher -d path/to/directory -u
-r Recursion. This instructs caseswitcher to recursively go through the directory and change the names of all files and sub-folders to the specified case caseswitcher -d path/to/directory -l -u -r
-h Help. Displays a help message. Please note that supplying this option will make caseswitcher display the help message and exit even if you supplied any other option. caseswitcher -h
-v Verbose. This instructs CaseSwitcher to print to the terminal what it is doing. caseswitcher -d /path/to/directory -l -v

cli-caseswitcher's People

Contributors

yeboahnanaosei avatar

Stargazers

Freddy Dro avatar

Watchers

James Cloos avatar

cli-caseswitcher's Issues

A way to ignore specific filenames

Files like README, LICENSE and CHANGELOG are more or less standards now. They usually come in specific caps. It will be nice to have CaseSwitcher ignore such common filename and leave them as such.
Perhaps with a -i option to ignore common filenames. This will mean a list of common filenames will have to be agreed upon and added to the system.

It will also be nice if the user can also specify their own set of directory or filenames to ignore.
yeboahnanaosei/caseswitcher#2

Possibly change all filename references within code to match the changed filenames

CaseSwitcher switches filenames to either lowercase or uppercase. This will definitely break any reference to the file within the code. It will be very great if CaseSwitcher could go through all affected files and correctly change references to the affected files to the right case.

eg. Assuming you have a project with 2 files file1.html and file2.html. Inside file1.html you have a link to file2.html like this <a href="file2.html">Link to file2.html</a>.
Using CaseSwitcher, you change the name of file2.html to FILE2.html. This will break the link. It will be nice if CaseSwitcher could go into file1.html and change the link to correctly reference the new name

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.