procedure tfixname (file_out, startNum, stopNum, prefixIN, extnIN, padIN, prefixOU, extnOU, padOU) string file_out {prompt="Name of Unix-executable `mv' command file"} int startNum {1, prompt="Number of first file"} int stopNum {prompt="Number of last file"} string prefixIN {prompt="Prefix for input filenames"} string extnIN {prompt="Extension for input filenames (dot included)"} bool padIN {no, prompt="Pad numbers of input filenames?"} string prefixOU {prompt="Prefix for output filenames"} string extnOU {prompt="Extension to add to output filenames (dot included)"} bool padOU {yes, prompt="Pad numbers of output filenames?"} begin int i string thouZero # optional extra zero if images run into 1000s string oldFilename string newFilename string commandLine thouZero = "" if (stopNum > 999) { thouZero = "0" } for (i=startNum; i<=stopNum; i+=1) { oldFilename = prefixIN//i//extnIN newFilename = prefixOU//i//extnOU # initially assume unpadded filenames; then change if req'd # thouZero = "" # Padding number in old filename if req'd: if (padIN==yes) { if (i<10) { oldFilename=prefixIN//thouZero//"00"//i//extnIN } else if (i<100) { oldFilename=prefixIN//thouZero//"0"//i//extnIN } else if (i<1000) { oldFilename=prefixIN//thouZero//i//extnIN } else { oldFilename=prefixIN//i//extnIN } } # thouZero = "0" # Padding number in new filename if req'd: if (padOU==yes) { if (i<10) { newFilename=prefixOU//thouZero//"00"//i//extnOU } else if (i<100) { newFilename=prefixOU//thouZero//"0"//i//extnOU } else if (i<1000) { newFilename=prefixOU//thouZero//i//extnOU } else { newFilename=prefixOU//i//extnOU } } commandLine = "mv "//oldFilename//" "//newFilename print(commandLine, >> file_out) } # Printing a sample line (the last) from the mv-file: print(file_out) print("last line:") print(commandLine) end