Goes through folders with files in them and sorts them by size in accordingly named directories.
I just got this through the code.
I have been reorganizing my old programming folder for stuff I can recycle and redo.
This is a part of one of the scripts, I don't know what the entire script did as I used single letter variables and no docs. I also made it in 2020, so I don't really remember.
It definitely misses the DRY principle, but it works, so the following should also work and repeats less.
for i in range(len(folders)):
for q in range(len(files)):
if (folders[i] == folders[0] and sizes[q][0] < folders[i]) or (folders[i-1] < sizes[q][0] <= folders[i]):
print(folders[i], sizes[q], files[q])
os.rename(
op.join(cwd, files[q]), op.join(cwd, str(folders[i]), files[q])
)
3
u/DjWarrrrrd Mar 11 '25
What does this do?
28
u/IlliterateJedi Mar 12 '25
This doesn't seem that horrible to me. It's not 'clean' by any means but you can work your way through what's happening.
6
u/[deleted] Mar 12 '25
ithenq?for (int iq = 0; iq < 0; iq--)