22.02.21 [kfood프로젝트] 음식사진 빅데이터 파이썬 .JPG , .png등을 .jpg로 바꾸기

2022. 2. 21. 20:17프로젝트/KFood

.JPG가 섞여있었다.(난 .png는 굳이 안바꿔도 되서 그냥 냅둠)

for i in os.listdir('./kfood'):
    print(f'{i}--------------------------------')
    for j in os.listdir(f'./kfood/{i}'):
        print('\t',j)
        for filename in os.listdir(f'./kfood/{i}/{j}'):
            if filename[-4:]=='.JPG':       
                print(f'./kfood/{i}/{j}/'+filename, '=>', f'./kfood/{i}/{j}/'+filename[:-4]+'.jpg')
                os.rename(f'./kfood/{i}/{j}/'+filename, f'./kfood/{i}/{j}/'+filename[:-4]+'.jpg')

 

output

구이--------------------------------
	 갈비구이
	 갈치구이
	 고등어구이
./kfood/구이/고등어구이/Img_002_0586.JPG => ./kfood/구이/고등어구이/Img_002_0586.jpg
./kfood/구이/고등어구이/Img_002_0597.JPG => ./kfood/구이/고등어구이/Img_002_0597.jpg
./kfood/구이/고등어구이/Img_002_0648.JPG => ./kfood/구이/고등어구이/Img_002_0648.jpg
./kfood/구이/고등어구이/Img_002_0651.JPG => ./kfood/구이/고등어구이/Img_002_0651.jpg
./kfood/구이/고등어구이/Img_002_0653.JPG => ./kfood/구이/고등어구이/Img_002_0653.jpg
./kfood/구이/고등어구이/Img_002_0655.JPG => ./kfood/구이/고등어구이/Img_002_0655.jpg
./kfood/구이/고등어구이/Img_002_0656.JPG => ./kfood/구이/고등어구이/Img_002_0656.jpg
./kfood/구이/고등어구이/Img_002_0657.JPG => ./kfood/구이/고등어구이/Img_002_0657.jpg
./kfood/구이/고등어구이/Img_002_0658.JPG => ./kfood/구이/고등어구이/Img_002_0658.jpg
./kfood/구이/고등어구이/Img_002_0659.JPG => ./kfood/구이/고등어구이/Img_002_0659.jpg
./kfood/구이/고등어구이/Img_002_0660.JPG => ./kfood/구이/고등어구이/Img_002_0660.jpg
./kfood/구이/고등어구이/Img_002_0661.JPG => ./kfood/구이/고등어구이/Img_002_0661.jpg
./kfood/구이/고등어구이/Img_002_0662.JPG => ./kfood/구이/고등어구이/Img_002_0662.jpg
./kfood/구이/고등어구이/Img_002_0663.JPG => ./kfood/구이/고등어구이/Img_002_0663.jpg
./kfood/구이/고등어구이/Img_002_0664.JPG => ./kfood/구이/고등어구이/Img_002_0664.jpg
./kfood/구이/고등어구이/Img_002_0665.JPG => ./kfood/구이/고등어구이/Img_002_0665.jpg
./kfood/구이/고등어구이/Img_002_0666.JPG => ./kfood/구이/고등어구이/Img_002_0666.jpg
./kfood/구이/고등어구이/Img_002_0667.JPG => ./kfood/구이/고등어구이/Img_002_0667.jpg
./kfood/구이/고등어구이/Img_002_0668.JPG => ./kfood/구이/고등어구이/Img_002_0668.jpg
./kfood/구이/고등어구이/Img_002_0679.JPG => ./kfood/구이/고등어구이/Img_002_0679.jpg
./kfood/구이/고등어구이/Img_002_0680.JPG => ./kfood/구이/고등어구이/Img_002_0680.jpg
./kfood/구이/고등어구이/Img_002_0681.JPG => ./kfood/구이/고등어구이/Img_002_0681.jpg
./kfood/구이/고등어구이/Img_002_0693.JPG => ./kfood/구이/고등어구이/Img_002_0693.jpg
./kfood/구이/고등어구이/Img_002_0698.JPG => ./kfood/구이/고등어구이/Img_002_0698.jpg
	 곱창구이
	 닭갈비
./kfood/구이/닭갈비/Img_004_0001.JPG => ./kfood/구이/닭갈비/Img_004_0001.jpg
./kfood/구이/닭갈비/Img_004_0002.JPG => ./kfood/구이/닭갈비/Img_004_0002.jpg
./kfood/구이/닭갈비/Img_004_0003.JPG => ./kfood/구이/닭갈비/Img_004_0003.jpg
./kfood/구이/닭갈비/Img_004_0004.JPG => ./kfood/구이/닭갈비/Img_004_0004.jpg
./kfood/구이/닭갈비/Img_004_0008.JPG => ./kfood/구이/닭갈비/Img_004_0008.jpg
./kfood/구이/닭갈비/Img_004_0009.JPG => ./kfood/구이/닭갈비/Img_004_0009.jpg
./kfood/구이/닭갈비/Img_004_0013.JPG => ./kfood/구이/닭갈비/Img_004_0013.jpg
./kfood/구이/닭갈비/Img_004_0946.JPG => ./kfood/구이/닭갈비/Img_004_0946.jpg
./kfood/구이/닭갈비/Img_004_0947.JPG => ./kfood/구이/닭갈비/Img_004_0947.jpg
./kfood/구이/닭갈비/Img_004_0948.JPG => ./kfood/구이/닭갈비/Img_004_0948.jpg
./kfood/구이/닭갈비/Img_004_0949.JPG => ./kfood/구이/닭갈비/Img_004_0949.jpg
./kfood/구이/닭갈비/Img_004_0953.JPG => ./kfood/구이/닭갈비/Img_004_0953.jpg
./kfood/구이/닭갈비/Img_004_0954.JPG => ./kfood/구이/닭갈비/Img_004_0954.jpg
./kfood/구이/닭갈비/Img_004_0958.JPG => ./kfood/구이/닭갈비/Img_004_0958.jpg
	 더덕구이
./kfood/구이/더덕구이/Img_005_0006.JPG => ./kfood/구이/더덕구이/Img_005_0006.jpg
./kfood/구이/더덕구이/Img_005_0032.JPG => ./kfood/구이/더덕구이/Img_005_0032.jpg
./kfood/구이/더덕구이/Img_005_0033.JPG => ./kfood/구이/더덕구이/Img_005_0033.jpg
./kfood/구이/더덕구이/Img_005_0034.JPG => ./kfood/구이/더덕구이/Img_005_0034.jpg
./kfood/구이/더덕구이/Img_005_0036.JPG => ./kfood/구이/더덕구이/Img_005_0036.jpg
./kfood/구이/더덕구이/Img_005_0037.JPG => ./kfood/구이/더덕구이/Img_005_0037.jpg
./kfood/구이/더덕구이/Img_005_0038.JPG => ./kfood/구이/더덕구이/Img_005_0038.jpg
./kfood/구이/더덕구이/Img_005_0040.JPG => ./kfood/구이/더덕구이/Img_005_0040.jpg
./kfood/구이/더덕구이/Img_005_0043.JPG => ./kfood/구이/더덕구이/Img_005_0043.jpg
./kfood/구이/더덕구이/Img_005_0045.JPG => ./kfood/구이/더덕구이/Img_005_0045.jpg
./kfood/구이/더덕구이/Img_005_0055.JPG => ./kfood/구이/더덕구이/Img_005_0055.jpg
./kfood/구이/더덕구이/Img_005_0959.JPG => ./kfood/구이/더덕구이/Img_005_0959.jpg
./kfood/구이/더덕구이/Img_005_0985.JPG => ./kfood/구이/더덕구이/Img_005_0985.jpg
./kfood/구이/더덕구이/Img_005_0986.JPG => ./kfood/구이/더덕구이/Img_005_0986.jpg
./kfood/구이/더덕구이/Img_005_0987.JPG => ./kfood/구이/더덕구이/Img_005_0987.jpg
./kfood/구이/더덕구이/Img_005_0989.JPG => ./kfood/구이/더덕구이/Img_005_0989.jpg
./kfood/구이/더덕구이/Img_005_0990.JPG => ./kfood/구이/더덕구이/Img_005_0990.jpg
./kfood/구이/더덕구이/Img_005_0991.JPG => ./kfood/구이/더덕구이/Img_005_0991.jpg
./kfood/구이/더덕구이/Img_005_0993.JPG => ./kfood/구이/더덕구이/Img_005_0993.jpg
./kfood/구이/더덕구이/Img_005_0996.JPG => ./kfood/구이/더덕구이/Img_005_0996.jpg
./kfood/구이/더덕구이/Img_005_0998.JPG => ./kfood/구이/더덕구이/Img_005_0998.jpg
	 떡갈비
./kfood/구이/떡갈비/Img_006_0005.JPG => ./kfood/구이/떡갈비/Img_006_0005.jpg
./kfood/구이/떡갈비/Img_006_0010.JPG => ./kfood/구이/떡갈비/Img_006_0010.jpg
./kfood/구이/떡갈비/Img_006_0067.JPG => ./kfood/구이/떡갈비/Img_006_0067.jpg
./kfood/구이/떡갈비/Img_006_0069.JPG => ./kfood/구이/떡갈비/Img_006_0069.jpg
./kfood/구이/떡갈비/Img_006_0070.JPG => ./kfood/구이/떡갈비/Img_006_0070.jpg
./kfood/구이/떡갈비/Img_006_0071.JPG => ./kfood/구이/떡갈비/Img_006_0071.jpg
./kfood/구이/떡갈비/Img_006_0074.JPG => ./kfood/구이/떡갈비/Img_006_0074.jpg
./kfood/구이/떡갈비/Img_006_0075.JPG => ./kfood/구이/떡갈비/Img_006_0075.jpg
./kfood/구이/떡갈비/Img_006_0076.JPG => ./kfood/구이/떡갈비/Img_006_0076.jpg
./kfood/구이/떡갈비/Img_006_0077.JPG => ./kfood/구이/떡갈비/Img_006_0077.jpg
./kfood/구이/떡갈비/Img_006_0078.JPG => ./kfood/구이/떡갈비/Img_006_0078.jpg
./kfood/구이/떡갈비/Img_006_0080.JPG => ./kfood/구이/떡갈비/Img_006_0080.jpg
./kfood/구이/떡갈비/Img_006_0081.JPG => ./kfood/구이/떡갈비/Img_006_0081.jpg
./kfood/구이/떡갈비/Img_006_0083.JPG => ./kfood/구이/떡갈비/Img_006_0083.jpg
./kfood/구이/떡갈비/Img_006_0084.JPG => ./kfood/구이/떡갈비/Img_006_0084.jpg
./kfood/구이/떡갈비/Img_006_0091.JPG => ./kfood/구이/떡갈비/Img_006_0091.jpg
./kfood/구이/떡갈비/Img_006_0092.JPG => ./kfood/구이/떡갈비/Img_006_0092.jpg
./kfood/구이/떡갈비/Img_006_0093.JPG => ./kfood/구이/떡갈비/Img_006_0093.jpg
./kfood/구이/떡갈비/Img_006_0118.JPG => ./kfood/구이/떡갈비/Img_006_0118.jpg
./kfood/구이/떡갈비/Img_006_0133.JPG => ./kfood/구이/떡갈비/Img_006_0133.jpg
./kfood/구이/떡갈비/Img_006_0151.JPG => ./kfood/구이/떡갈비/Img_006_0151.jpg
./kfood/구이/떡갈비/Img_006_0152.JPG => ./kfood/구이/떡갈비/Img_006_0152.jpg
./kfood/구이/떡갈비/Img_006_0973.JPG => ./kfood/구이/떡갈비/Img_006_0973.jpg
./kfood/구이/떡갈비/Img_006_0978.JPG => ./kfood/구이/떡갈비/Img_006_0978.jpg
	 불고기
./kfood/구이/불고기/Img_007_0023.JPG => ./kfood/구이/불고기/Img_007_0023.jpg
./kfood/구이/불고기/Img_007_0024.JPG => ./kfood/구이/불고기/Img_007_0024.jpg
./kfood/구이/불고기/Img_007_0035.JPG => ./kfood/구이/불고기/Img_007_0035.jpg
./kfood/구이/불고기/Img