Is it possible to move by means of os.rename or shutil.move all the files in a directory to a a subdirectory of the same directory?
For example if I have the following structure:
- Dir_1
- File_1
- File_2
- subDir_1
can I get the following structure:
- Dir_1
- subDir_1
- File_1
- File_2 ?
- subDir_1
Best.-
EDIT: In the end I solved my problem using the following code:
for fname in os.listdir(src):
if os.path.isfile(os.path.join(src, fname)):
os.rename(os.path.join(src, fname), os.path.join(dst, fname))
Thanks a lot to both of you!
listdir
: stackoverflow.com/questions/3207219/…