Rename multiple files

When we want to rename a file (with Linux or Mac OS), we  generally go to the directory of the file and we rename the file. Or for those who prefer doing with the terminal, we use mv

Capture d_écran 2017-04-27 à 22.55.03

And how about multiple file ? How about renaming all episode of Game of Throne ?Capture d_écran 2017-04-27 à 23.02.11

  • How can we remove [TOTO] for every file name ?
  • How can we rename secretFile for every file name ?
  • How can we remove the extension for every file name ?
  • How can we upper case every file name ?
  • and so on …

we generally do

  • one by one
  • or a bash script

are-you-serious-wtf-meme-baby-face

or

Boss-Baby-with-Briefcase01

To rename multiple files, we will use rename. But what’s rename ?

Rename is a program that renames files according to modification rules specified on the command line.

Install rename program

To install rename, we will use homebrew (a package manager for OSX. With homebrew we can install a lot of applications and libraries that would require manual compilation)

  1. open the terminal
  2. enter “brew install rename”
  3. done

Or use Cakebrew (The Mac App for Homebrew)

Capture d’écran 2017-04-27 à 22.27.10.png

Now let’s rename:

Append the string argument you supply to every filename: rename -a ‘ toto’ *
(-a: append the string argument you supply to every filename)

Capture d_écran 2017-04-27 à 23.17.09

Prepend the string argument you supply to every filename: rename -A ‘ toto’ *
(-A: prepend the string argument you supply to every filename)

Capture d’écran 2017-04-27 à 23.18.22.png

Convert file names to all lower case: rename -c -f *
(-c: convert file names to all lower case)
(-f: rename even when a file with the destination name already exists)

Capture d’écran 2017-04-27 à 23.20.15.png

Convert file names to all upper case: rename -C -f *
(-c: convert file names to all upper case)

Capture d’écran 2017-04-27 à 23.19.25.png

Remove the last extension from a filename, if there is any: rename -x *

Capture d’écran 2017-04-27 à 23.21.11.png

Replace all sequences of whitespace in the filename with single underscore characters: rename –nows *

Capture d’écran 2017-04-27 à 23.22.19.png

Replace each underscore in the filename with a space: rename –rews *

Capture d’écran 2017-04-27 à 23.23.21.png

Perform a simple textual substitution of “from” to “to”:
rename -s ‘want to change’ ‘to what we want’ *

Capture d’écran 2017-04-27 à 23.24.53.png

Add increment number for each file in the list from 1: rename -N …01 -X -e ‘$_ = “$_-$N”‘ *
(-X  stand for keep the extension)
(-e stand for expression)
($_ is the name of the file in the expression)
($N is the incrementation number in the expression)

Capture d’écran 2017-04-27 à 23.26.24.png

Add increment number for each file in the list from 3rename -N …03 -X -e ‘$_ = “$_-$N”‘ *

Capture d’écran 2017-04-27 à 23.27.29.png

Throw away all the existing filenames and simply number the files from 1rename -N …01 -X -e ‘$_ = “FileName-$N”‘ *

Capture d’écran 2017-04-27 à 23.28.43.png

That was only the surface of the iceberg. To see other parameter use:

man rename 

Cool isn’t it ?
So let rename it !
359207_m1469233525

Advertisements
Rename multiple files

How to install WildFly on Windows

Formerly known as JBoss AS or simply JBoss, WildFly is a fantastic full-featured multiplaform open-source and free application server authored by Red Hat.

This quick tutorial will list the steps to install this AS on a Windows machine.

PREREQUISITE: Install the lastest Java Development Kit (JDK)

To be able to run the AS, you will need a compatible JDK (JDK 7 Update 75 or later), if possible the lastest available on the Oracle website.

  1. Go to this link and download the lastest JDK (e.g. jdk-8u91-windows-x64.exe).
  2. Change the installation directory to c:\Java\jdk{your-version} (e.g. jdk1.8.0_91)screen1This should be like:screen2
  3. Create an environment variable JAVA_HOME for your system.
    1. On your keyboard, press windows+break
    2. Click on ‘Advanced System Configuration’
    3. Under ‘Environment variables’, add the variable JAVA_HOME with values ‘c:\Java\jdk{your-version}’screen3
    4. And add it to the Path variablescreen4
    5. You will need to close any command windows that were open before executing a command with this path, since there is no way to reload environment variables from an active command prompt.
    6. To check if the path variable is correctly configured, type ‘javac -version’ in the prompt. This will give you the version of the java compiler you installed.screen5

Installing WildFly 10

  1. Download the lastest stable version of the Enterprise Application Integration (EAI) server from the official website (Link). (E.g. wildfly-10.0.0.Final.zip)
  2. Extract the zip archive to C:\EAI. Your system will create a brand new folder named ‘wildfly-10.0.0.Final’ under C:\EAI.
  3. Execute the script ‘C:\EAI\wildfly-10.0.0.Final\bin\standalone.bat‘ to set up the bootstrap environment, check the installation and start the server.screen6
  4. After that the server has been started, you should be able to access the web server at the address http://localhost:8080 and to access to the console at http://localhost:8080/console.screen7

Configure WildFly server

Add a user to access to the console

To be able to access the admin console, you will need to add a new user by executing the script ‘add-user.bat’ located under your WildFly installation folder (e.g. c:\EAI\wildfly-10.0.0.Final).

  1. Execute the script ‘add-user.bat’ in a console window.
  2. Add a Management User by just typing ‘enter’ since this is the default option.screen0
  3. Enter the details of the new user to add as described. (e.g. ‘admin’ and ‘1234’ for a local installation).
  4. Revisit the server console at localhost:9990/console and enter your credentials.
  5. Now, you should be able to see thisscreen1
How to install WildFly on Windows