Rename a batch of textfiles
I have thousands of textfiles inside a directory and they are named in a certain way. For eg:
Image_234_Data_7778_n0.txt
Image_234_Data_7778_n1.txt
Image_234_Data_7778_n2.txt
Image_954_Data_4478_n0.txt
Image_954_Data_4478_n1.txt
Image_954_Data_4478_n2.txt
Image_104_Data_9878_n0.txt
Image_104_Data_9878_n1.txt
Image_104_Data_9878_n2.txt
and so on...
I would like to make a sourcefile (which would be used to rename the files and keep track of 'which is which') that should read:
1_1.txt:Image_234_Data_7778_n0.txt
1_2.txt:Image_234_Data_7778_n1.txt
1_3.txt:Image_234_Data_7778_n2.txt
2_1.txt:Image_954_Data_4478_n0.txt
2_2.txt:Image_954_Data_4478_n1.txt
2_3.txt:Image_954_Data_4478_n2.txt
3_1.txt:Image_104_Data_9878_n0.txt
3_2.txt:Image_104_Data_9878_n1.txt
3_3.txt:Image_104_Data_9878_n2.txt
and so on...
Can anyone help me with some code which would do this for me? Any help would be highly appreciated !
Last edited by tofayel001; 08-11-2014 at 09:31 AM.
|