Click here to Skip to main content
14,767,265 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a directory with files and I filtered to *.html with glob.

I want those files to save in another directory one by one with for loop.

Another directory= "path"

What I have tried:

path = 'directory'

for filelist in glob.glob('*.html'):


How do I save filelist to "path"
Posted
Updated 3-Sep-20 3:43am

1 solution

You can either use shutil[^] OR os[^]

Example:-
Using shutil
import shutil

shutil.move("pathA/file1.html", "pathB/file1.html")

Using os:
import os

# either of below line will do
os.rename("pathA/file1.html", "pathB/file1.html")
os.replace("pathA/file1.html", "pathB/file1.html")

Now, with your code, you need to run them in your loop to make it happen.
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900