command line – How to ‘correctly’ make this file reorganization python script prompt for user input, check for validity, and then double check?

I have a modified version of this really cool script that was written the better half of a decade ago to reorganize really large folders full of random files into their respective directories. My modifications are irrelevant to the question, so I’ll use the original script in my example below.

I’ve set it to prompt for user input instead of hardcoding variables into the script (shown below in between the “MY CURRENT EDITS” comments) and that seems to work well enough, but I am worried that it might end up accidentally eating an entire directory I don’t intend it to work on if I make a mistake.

1.) Is there a means by which I can make it prompt the user for the “reorg_dir” in such a way it lets a user scroll through directories, select a directory, and then double check to make sure the user is happy with what will happen?

2.) In the same vein, is there a means by which one could be prompted to exclude some filetype, else it excludes nothing?

3.) Continuing, how about remove_emptyfolders, else assume True ?

#!/usr/bin/env python3

import os
import subprocess
import shutil

# --------------------------------------------------------
reorg_dir = "/path/to/directory_to_reorganize"
exclude = (".jpg") # for example
remove_emptyfolders = True
# ---------------------------------------------------------

# MY CURRENT EDITS ---------------------------------------
while True:
    dirReorg= input("What directory do you want to organize by filetype?")
    if not os.path.exists(dirReorg):
        print("That path doesn't exist. Try again!")
reorg_dir = os.path.abspath(dirReorg)
# end MY CURRENT EDITS -----------------------------------

for root, dirs, files in os.walk(reorg_dir):
    for name in files:
        subject = root+"/"+name
        if name.startswith("."):
            extension = ".hidden_files"
        elif not "." in name:
            extension = ".without_extension"
            extension = name(name.rfind("."):)
        if not extension in exclude:
            new_dir = reorg_dir+"/"+extension(1:)
            if not os.path.exists(new_dir):
            shutil.move(subject, new_dir+"/"+name)

def cleanup():
    filelist = ()
    for root, dirs, files in os.walk(reorg_dir):
        for name in files:
    directories = (item(0) for item in os.walk(reorg_dir))
    for dr in directories:
        matches = (item for item in filelist if dr in item)
        if len(matches) == 0:
            except FileNotFoundError:

if remove_emptyfolders == True:

ms dos – How to get a DOS prompt or even boot into Dos on windows 10?

DOS is a 16-bit system and will never install directly on a machine made for Windows 10. The CPU and board are too new and different and will not run 16-bit software.

Your only hope is a Virtual Machine – I have a DOS 6.3 VM right here.

You could look on eBay for a very old computer but that has its own risks with age and may not even boot DOS, but it might.

How to re-install command prompt in windows 10, if it’s suddenly missing from the system?

This morning, cmd.exe is missing from my computer (Windows 10), from the regular path C:windowsSystem32cmd.exe. Please don’t advice on location check. My query is –

  1. Is this a serious issue? Like some kind of malware attack?

  2. Is it possible to get back / re-install command prompt (results from google / youtube are not helpful). I don’t have a recovery partition.

node.js – Erro no JavaScript. “prompt não definido”

O prompt em referência é uma biblioteca, se você já a tem instalada, apenas importe a biblioteca para o seu script, se não, instale via NPM.
Caso vá instalar, recomendo o prompt-sync por comodidade, não será necessário alterar nada no seu código já que o mesmo é chamado via prompt(). Instale-o rodando o comando npm i prompt-sync e o importe para seu script adicionando const prompt = require('prompt-sync')(); logo no início do mesmo.

Ao instalar a biblioteca, certifique-se de estar no mesmo diretório.

Observe que após realizado o procedimento, a cada caractere digitado no terminal uma linha será adicionada, isso acontece por conta do caractere de escape n, remova-o em todos os prompt() para corrigir o comportamento.

How do I change the default command prompt directory in windows 7?

When I open command prompt it’s now defaulting to the user folder rather than system32 as it used to.

How do I permanently change it back to system32 like it’s supposed to be rather than just a temporary CD command?

I have read that this change has occurred due to an installed program changing an environment variable but not sure how to correct it.

This is a windows 7 machine so there is no right click “open in file location” setting.

Thank you.

authentication – How to force web sites and services to stop resetting passwords of accounts without user’s permission and prompt?

A new trend in account security is spreading: web services like LinkedIn reset passwords automatically when detect attempts of getting access with wrong password or from new locations. Thus, a user has to restore password every time when not using 2-Factor Authentication. The problem is that most support services ignore the rationale below. However, the LinkedIn support, to their credit, escalated the feature request for a setting “don’t reset password on failed or suspicious login attempts” to their developing team.

The root reason of password resetting is that web services like Google and LinkedIn began using contacts (mobile phone numbers and emails) as logins. By this way, these services shared logins to everyone and thus made possible brute-force attacks on passwords for many accounts simultaneously. In other words, these company canceled the first secure factor of authentication.

Previously, the user created a login, which is unknown to all by default. This login was the first secure factor for authentication. And this way was secure enough when protected with a strong password. That is why the common way of getting access by an attacker was to find out the email to restore password and hacking an email box. These services must return secure logins to user accounts to stop brute forcing attacks on passwords.

Then, to plug this self-made security hole, these services reinvented 2-Factor Authentication by introducing secure temporary codes sent by another channel to the user. However, the use of mobile phone as a central secure device makes possible to get or lose access to all accounts at once. An attacker can easily steal a mobile device or SIM card. Another case is the impossibility to read a secure temporary code sent by a web service. There are too many reasons for that, beginning from broken display and unavailable mobile service. That is why 2-Factor Authentication has increased the risk of losing access to all accounts at once.

To avoid this risk, many users disabled 2-Factor Authentication, especially after losing access to their accounts because of broken display. Then, web services have invented a new way of irritating users and wasting their time: they began to reset passwords for accounts automatically on failed attempts of logging into or on other unexplained reasons. And now, users have to restore passwords every time because attackers reset passwords by brute-forcing them continuously. Another trivial case is the user’s device with old password and the mobile app using it for getting regular updates.

Thus, these services manipulate users to force them using 2-Factor Authentication: to restore password the secure temporary code is sent. But an attacker does not have a chance to brute force strong passwords, which these services require from users. Otherwise such passwords are not considered strong, by definition. And the user location of login into does not matter in such case also.

In short, here’s two questions: how to get such services to stop resetting passwords of accounts without user’s permission and prompt? How to end this terrible trend of total neglect of user’s choice in balance between risks, usability and reliability? It is especially important for IT professionals themselves because they should be able to take care on that.