bug in file renamer
This commit is contained in:
parent
1e136ff080
commit
bc2001ac7f
|
@ -4,7 +4,6 @@ dependencies:
|
|||
- aiofiles>=22.1.0
|
||||
- colorama>=0.4.5
|
||||
- aiohttp>=3.8.3
|
||||
#- open_clip_torch>=1.26.12
|
||||
- timm
|
||||
- fairscale==0.4.4
|
||||
- transformers==4.19.2
|
||||
|
|
|
@ -60,7 +60,7 @@ def get_replace_list(opt):
|
|||
def rename_files(opt):
|
||||
find_list = get_replace_list(opt)
|
||||
|
||||
for idx, file in glob.iglob(opt.img_dir + "/*"):
|
||||
for idx, file in enumerate(glob.iglob(f"{opt.img_dir}/*")):
|
||||
print(file)
|
||||
|
||||
if os.path.splitext(file)[1] in (".jpg", ".png", ".jpeg", ".gif", ".bmp", ".webp"):
|
||||
|
@ -74,7 +74,7 @@ def rename_files(opt):
|
|||
try:
|
||||
print(f"Renaming {file} to {new_filename}")
|
||||
if os.path.exists(new_filename):
|
||||
new_filename = new_filename + "_" + idx
|
||||
new_filename = f"{new_filename}_{idx}"
|
||||
print(f"filename already exists, appended '_n' to {new_filename}")
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue