0
I am developing a script that checks the last access date of each file within every tree of a chosen directory. Files over X days without access will be moved to another directory. As a precaution, I need it detected if the destination directory is inside the source directory. If so, the script will ask for a destination directory other than within the source directory.
This is the part where the destination directory is requested:
msg_error = '[ERRO] Diretorio invalido, tente novamente:\n'
pasta_destino = str(input('Insira o diretorio de destino\n'))
while not path.isdir(pasta_destino):
pasta_destino = str(input(msg_error))
I’ve been trying to check this out for a long time, and I’ve tried everything. I’ve only been learning python for a week and something closer to the check I was able to assemble was this:
if path.exists(pasta_destino in pasta_origem):
print('Escolha outro diretório que não dentro do diretório de origem.\n')
Unfortunately it does not work, returns 'True' independent of the inserted paths.
I’m sure this is a simple check, can you help me? Thank you very much.
It only works if the directory is immediately inside the other, IE, can not detect the case of
directory
checking to be at 2 or more subdirectory levels inside the root directoryroot
.– nosklo
@nosklo, I focused on the question, and I didn’t realize this need, but it would be very simple to adapt to what you suggest.
– Sidon