Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
add leading zeros to a variable?

Posted by redstapler (redstapler), 4 December 2007
I have a variable incrementing in a loop that is appended to a file name, so they are outputted like: file1.bmp, file2.bmp etc.. though I need them like this: file001.bmp, file002.bmp. I tried doing set var [printf %03d $var] but the variable it returns is always empty.

Posted by admin (Graham Ellis), 4 December 2007
Have you tried replacing printf with format?



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho