Renumbering image sequences (PowerShell)

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
Posts: 338
Joined: Tue Nov 12, 2013 2:05 am

Renumbering image sequences (PowerShell)

Post by peter_b »

Code: Select all

$FOLDER = "C:\wherever\myfilm";

$i = 1;

$files=Get-ChildItem $FOLDER -Filter *.tif

Foreach($obj in $files){
   $index= "{0:000000}" -f $i;

   $pathWithFilename=$FOLDER +"\"+ $obj.Name;
   $out=$FOLDER + "\LLUVIA.$index.tif";

   Write-Output "In: $in";
   Write-Output "out: $out";
   Rename-Item -Path $in -NewName $out;

   Write-Output "-"
User avatar
Site Admin
Posts: 1469
Joined: Fri Aug 29, 2003 8:39 pm

Re: Renumbering image sequences (.bat)

Post by ^rooker »

I found this piece of code in my notes.
I don't know if it ever worked though, and it may be a copy/paste from a forum or website:

Code: Select all

@echo off

set N=0
set FILENAME=baseFileName.%N%.tif

set /a N+=1
set FILENAME=baseFileName.%N%.tif
if exist %FILENAME% goto :loop

echo You can safely use this name %FILENAME% to create a new file

But maybe it has elements of truth in it that may be useful for someone else?
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply