The accepted answer is not the right one, because the question is not about renaming a file into a file, but moving many files into a directory. shutil.move
will do the work, but for this purpose os.rename
is useless (as stated on comments) because destination must have an explicit file name.