2
I’m creating a python script to rename folder names that are lowercase to uppercase. In the code example below I already get this task.
import os
basedir = '/content/drive/My Drive/Colab Notebooks/Teste'
for name_folder in os.listdir(basedir):
os.rename(os.path.join(basedir, name_folder),
os.path.join(basedir, name_folder.upper()))
I would like more information about the base directory files (base)
Questions:
1. Total number of files.
2. Total number of folders.
3. Total number of pulp processed.
I guess you forgot to rename the
basedir
fordiretorio_base
there on the second line.– Rfroes87
Thanks for the remark. I already edited the question.
– Nascin
@Rfroes87, your answer was exactly what I wanted. Thanks.
– Nascin
@Rfroes87, I’m changing the code a little bit, is there an easy way to implement a review if the path is really a directory?
dir = str(input('Digite um caminho: '))
– Nascin
You can use the function
os.path.isdir
.– Rfroes87