rename files, log them in table format

I have a problem, i can read and write to files, and i can also write to files in a list, well sort of, but i dont know how to log everything i need to do.

Basically what i want to do is copy a file to a new folder, rename that new file using thew following foprmat

R00001-CF.jpg < the 00001 has to increment.

I then need to write the old filename and new filename this way into a log file
oldfile – newfile

i think i know some, like how to write the line, but i am confused as to what to do on the next file. As i cant think of a way to new line it.

so something like this:

write (oldFile & " – " & newfile) starting at eof

actually just realised that if i add & return after newfile it will work, but i still dont get the rename bit. Is what i said right???

and does anyone know w way to increment files the way i would like.

R00001-CF.jpg
R00002-CF.jpg
R00008-CF.jpg
R00009-CF.jpg
R00010-CF.jpg

To increment the file names, just use a number coerced to a string to create the filename. To pad it with zeros, create a function that adds zeros to the beginning of the string until the string is the right length.