Rename using leading zeros

Hi, i'm hoping someone could help me rename all filenames to 13 digits by adding zeros to the front (padding). The result would be all files of the same length (13).

Starting name could be any number of digits but always less than or equal to 13.

For example
465646.eps========>0000000465646.eps
78978797.eps======>0000078978797.eps
789.eps===========>0000000000789.eps
5648796734523.eps==>5648796734523.eps

Thanks in advance for any help! This seems simple but after searching I can't seem to come up with anything. Very new to this.

You can do it with a rename script like this:

Script code:

function OnGetNewName(getNewNameData)
{
	var n = getNewNameData.newname_stem_m;
	while (n.length < 13)
	{
		n = "0" + n;
	}
	return n + getNewNameData.newname_ext_m
}

If you save that as a rename preset, you can then simply select it on the left, or via the menu at the right of the Rename button on your toolbar.

2 Likes

It's exactly perfect. Thank you Leo!

1 Like

This could be useful :+1: