View Full Version : 2 digit integer

12 December 2006, 03:03 PM
Hi folks,

I'm new to Mel, and currently doin a batch for creating folders script.

Is there any way that everytime I execute a script, it creates folder as 2 digits number e.g sc_01 instead of sc_1 ?(I tried ## but apparently it's only available in maya).


12 December 2006, 06:01 PM
Try something like this:

$newdigits = "23";
$ndigits = 5;

$nnewdigits = `size $newdigits`;

while ($ndigits > $nnewdigits) {
$newdigits = "0" + $newdigits;
print ($newdigits + "\n");

$newdigits contains the number you want at the end of the directory and $ndigits is the number of digits you want (2 in your case).

Take this number and append it to your base directory name and then create the directory (using sysFile or whatever).

BTW, I shamelessly stole this fragment from David Gladstein's incrementalSave mel script off Highend3d. I couldn't find or think of an easier way to do this.

--- David

12 December 2006, 04:02 AM
Thanks for your reply David.

It's easy to understand after reading your explanation.

I also read dpSaveScenePlus from Diego Prilusky but it's hard for me to understand :banghead:

Again, thank you David (*both David :lol:)

CGTalk Moderation
12 December 2006, 04:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.