Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- source='c:/users/ayanU/Desktop'
- destination='c:/users/ayanU/Desktop/text'
- #change the directory
- os.chdir(source)
- #look for text files
- files=os.listdir(source)
- ext=".txt"
- #make a loop to check all files and if .txt move to destination
- for file in files:
- if ext in file:
- shutil.move(file,destination)
Add Comment
Please, Sign In to add comment