I have a script that creates a list of local files by path name that I would like to see deleted. The essence of my problem in the code below.
If it's easier just to move these files rather than delete them, that's an option. I've seen it might be an option to set the directory before I can get it do delete but I'm hoping for a more efficient function that will just read the paths and deal with them.
I don't need any function to discriminate between any file path names stored in the list. I want each file stored in the list, OUT.
The code as is now gives the error:
TypeError: remove: illegal type for path parameter
Code:
import os
files = ['/users/computer/site/delete/photo1.jpg', '/users/computer/site/delete/photo3.jpg']
os.remove(files)
os.remove()
takes a single path as argument, not a list of paths. You have to do something like:
for f in files:
os.remove(f)