I've written the following script
import shutil,os,glob
# setting up destination folders
PYDEST = "/home/ubuntu/python-scripts/python-test"
TEXTDEST = "/home/ubuntu/python-scripts/texte-test"
def move8files(pwd):
PWD = pwd + "*"
for files in glob.glob(PWD):
if files.endswith(".txt"):
print(files)
shutil.move(files,TEXTDEST)
elif files.endswith(".py"):
shutil.move(files,PYDEST)
move8files("/home/ubuntu/python-scripts/")
Questions/Issues are the following:
- How can I make it simpler, especially by using the
os.listdir
but with having the pathname (listdir
does not give pathname)? - Would it be possible to include a part in my script, where instead of saying which folders are for python or text files, it will look syntaxically at specific folders containing words like
python
ortexte
in it? - What can I improve in my script, for better performance?