Python Forum

Full Version: Search for files and copy them to different location
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm a newbie so bear with me.

I have multiple duplicates of files on my network.

Is is possible to create something that can search that volume.
Find all the file extensions i'm looking for.
then move them to another volume but....
When they are moved take the folder path with them, so I know what folders they came from?

I basically have over 1k of files of a certain file type that I need moved, but need to move then and need to know what folders they were moved from.

Hope that makes sense.
Thanks,
Jay
You should first try some things out with this documentation about file and directory access. I'm sure what you want is possible with it.

Have you thought about how you want to deal with the original pathnames? How do you want to save this information? If you were able to copy or move a file you must have the path, which you can use then in any kind of way.

Ofcourse, when your code is not working we could dive into the details.
Thanks, I'll check it out.

As or the path names. Most of these file are buried in sub folders.

What I would want is, just to move them to another volume, in a folder that has the same job name as the original location it came from.

Thanks again.
Do I understand it right that you only want the folder where the file was in, without the whole path? for example: the path is folder1/folder2/file.txt, and you want only "folder2" and place the file in it on another volume?

You can do such things with os.path. This is mentioned in de link I have send.
Rather have folder1 and the file.txt in that

Or can something be written to create the whole path over to the new location. Only creating the folders and moving the file.txt?

Original location: folder1/folder2/folder3/folder4/file.txt
then the program runs and creates the folder path and moves the files in question.