I use Linux, I tried to rename all my image files in a folder using this code :
import os
i = 0
path = os.chdir("/home/saran/Documents/twitter content")
for file in os.listdir(path):
if file == "rename.py" :
continue
new_file = "tweet{}.png ".format(i)
os.rename(file, new_file)
i = i + 1
It worked and all files were renamed like this : tweet1.png tweet2.png tweet3.png tweet4.png,etc
but when I accidentally ran the code a second time, half of the image files were deleted... Is there any way to recover them? Looks like the files which have the same name were replaced cause I ran the code twice, I need to restore them, Is it possible to do it? Thanks!