Jeremy Richard moving pictures editor Est. 2008

{0:DX}

using PowerShell

Windows comes with a program called Powershell. This program, being at the same time the place (a shell) and the scripting language for executing automated actions, should be useable for renaming a series of images in one go by creating a loop which will rename any file found corresponding to the parameters previsouly set up.

For the following explanation we will assume that we have a series of tiff images (with the .tif extension), that are located inside a folder called ‘tunnel’. And we want to renumber these images tunnel_0001.tif, tunnel_0002.tif, tunnel_0003.tif and so on.

Process

  1. open Powershell, a console with a blue background appears;
  2. in Powershell, next to the PS line, go to the folder where the images are located using the cd (change directory) command: cd C:\*path*\tunnel;1
  3. once inside the folder (from Powershell’s console point of view) execute the following command: $i = 1 ; Get-ChildItem *.tif | ForEach-Object{Rename-Item $_ -NewName ('tunnel_{0:0000}.tif' -f $i++)}
  4. eventually, we can execute the dir (directory) command to list what is inside the folder and then check if the files have been renamed.
Screenshot of PowerShell
ForEach-Object creates the loop, Rename-Item execute the action

Explanation

What matters in this process is this line: $i = 1 ; Get-ChildItem *.tif | ForEach-Object{Rename-Item $_ -NewName ('tunnel_{0:0000}.tif' -f $i++)}. I will explain the bits that need to be understood in order to be able to customize them when having to use the action for a different scenario:

The End