Padding Zeros to an Index eg 10 becomes 0010

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

otherthings

Padding Zeros to an Index eg 10 becomes 0010

Post by otherthings »

The first several code snippets are potentially dangerous. What if the number you're starting with already has more digits than the maximum? In that case, the first digits will get cut off, e.g. 123456 will become 3456.

Andrew's final code snippet is the only one that behaves correctly in that case. (12 becomes 0012, but 123456 remains 123456).
Mike Hale

Padding Zeros to an Index eg 10 becomes 0010

Post by Mike Hale »

otherthings wrote:The first several code snippets are potentially dangerous.

That's true. But I think it clear from the thread that the first several posts don't contain valid code. This tread started in the 'help' section. Andrew moved it here because his last post is useful.

Mike
xbytor

Padding Zeros to an Index eg 10 becomes 0010

Post by xbytor »

We just went over this again recently:
http://ps-scripts.com/bb/viewtopic.php?t=1576

-X