Home>

Is there a good way to use python to move a csv with the same name in a different folder to a previously created folder and change the name to a sequential number?
By the way, the positional relationship of folders is the same.
Large folder-Medium folder-Small folder-csv
There are multiple files with different names in the folder, and csv has the same name.

If i have someone who knows the same function in the PC function even if it is not python, I would appreciate it if you could teach me.

  • Answer # 1

    import os
    import glob
    for i, f in enumerate (glob.glob ('Large folder/*/*/abc.csv')):
        os.rename (f, f'target/xyz {i} .csv ')


    How about feeling like?
    It is up to you to change the specific file pattern or to request zero padding.

Trends