D
D
Dmitry2016-06-22 15:32:16
System administration
Dmitry, 2016-06-22 15:32:16

What program to use under Windows to delete files according to the list?

I need a program that accepts a file with a list of files. Then she deletes files according to this list. At the same time, it supports shared disks and those mounted using the net command.
Here is what I expect from her in pseudocode:

def read_file_list(filename):
    result = None
    with open(filename, encoding='UTF-8') as f:
        result = f.readlines()
    return result

def remove_files(filenames):
    for path in filenames:
        filename = path[:-1]
        try:
            os.remove(filename)
        except FileNotFoundError as e:
            print('Not found: {}'.format(filename), file=sys.stderr)

def main(argv=None):
    file_list = sys.argv[1]
    files = read_file_list(file_list)
    remove_files(files)

I want a ready-made solution, not a crutch on my knee.
*UPD*
Subject to questions in the commentary.
The task in the question is not to write a script, but to find a program! The fact is that I will issue it to users, i.e. specify the URL. There is 100500 and another reason why users would prefer not to run the script. Passed. Checked. I know from experience that it's much easier to say the URL and for some reason it will work. I don't have to try to convince who is right and who is wrong, I just need to solve the user's problem

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
maaGames, 2016-06-22
@maaGames

If Windows, then PowerShell. A very powerful scripting language, more than meets your needs.

J
John Smith, 2016-06-22
@ClearAirTurbulence

You can try Deletist*
www.ghacks.net/2010/08/04/deletist-bulk-delete-fol...
Well, the PS command seems to work, and it is not a script (it may require some additional keys in some cases, like -recursive), although the potential problems for users when working with PS are clear:
Get-Content c:\path\to\list.txt | Remove-Item
DISCLAIMER: did not check the subject for performance, incl. in the mentioned TS use-case.

E
Evgeny Ferapontov, 2016-06-22
@e1ferapontov

BAT, Powershell. Why do you need some separate program, if all this is easily implemented using the built-in Windows command shells?

D
Dmitry Shitskov, 2016-06-22
@Zarom

Another non-answer to your question. The program is unknown to me. The script can be quickly thrown on the wonderful AutoIt. It compiles to exe and it is not necessary to specify your own copyrights. We can say that Uncle Vasya developed. I can be this Uncle Vasya myself, as a last resort. :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question