set pathlib to specific file name

299
August 25, 2017, at 04:01 AM

I have a script running to rename files, I want to upgrade/update it to looking at a certain file name.

The complete part

import pathlib
import shutil
import logging
def main(src, dest):
    logger = logging.getLogger("CopyFiles")
    logger.setLevel(logging.WARNING)
    handler = logging.FileHandler(filename = "CopyErrors.log",
                                  encoding = "utf-8",
                                  mode = "w")
    handler.setFormatter(logging.Formatter(
        "%(asctime)s - [%(levelname)s] %(name)s: %(message)s"))
    logger.addHandler(handler)
    pathSrc = pathlib.Path(src).rglob("lb_panoramic.csv")
    for file in pathSrc:
        try:
                shutil.copy(str(file), f"{dest}/{file.parent.name}.csv")
        except Exception as e:
               logger.warning(f"{file} could not be copied.\n"
                            f"{type(e).__name__}: {e}")
if __name__ == '__main__':
    main("C:/code/convert/renamefiles/source", "C:/code/convert/renamefiles/target")

Here still with

pathSrc = pathlib.Path(src).rglob("lb_panoramic.csv")

It does not take the file lb_panoramic.csv at all.??

Rent Charter Buses Company
READ ALSO
python 2.7 Tkinter reading environment variables

python 2.7 Tkinter reading environment variables

I am new to using Tkinter in pythyon 27 and am not able to read environment variables I defined on a raspberry pi

283
Python post request with Bearer token

Python post request with Bearer token

Im trying to make a script that post data on REST service together with Bearer token

1860
issue trying to implement a sum of subsets solution in python

issue trying to implement a sum of subsets solution in python

I am trying to write a brute-force solution to a sum of subsets problem in python but don't get any output

231
Mapping an Adjacency List to a Synonym List in Python

Mapping an Adjacency List to a Synonym List in Python

I have two python dictionaries that are structured as defaultdicts that follow the format {string:set(string)}They are as follows:

446