Python Forum
Search for files and copy them to different location
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search for files and copy them to different location
#1
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
Reply
#2
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.
- Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. Albert Einstein
Reply
#3
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.
Reply
#4
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.
- Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. Albert Einstein
Reply
#5
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 316 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Search string in mutliple .gz files SARAOOF 10 1,773 Aug-26-2021, 01:47 PM
Last Post: SARAOOF
  how search files Ron_Crafter 4 1,087 Apr-17-2021, 11:19 AM
Last Post: Ron_Crafter
  Merging all file_name.log's files from directory to one and search “PerformanceINFO" sutra 0 662 Dec-09-2020, 05:14 PM
Last Post: sutra
  Copy files from subfolders into same name of subfolders at other directory rathoreanil 1 1,062 Oct-12-2020, 01:30 AM
Last Post: Larz60+
  need to define date range of files to copy over OTH 4 1,191 Aug-07-2020, 12:29 PM
Last Post: buran
  Cannot copy file to another location rcmanu95 1 850 Jul-19-2020, 05:16 AM
Last Post: deanhystad
  Complex word search multiple files Kristenl2784 0 781 Jul-18-2020, 01:22 PM
Last Post: Kristenl2784
  How do I copy files without case sensitive? mcesmcsc 8 2,366 Dec-18-2019, 02:19 PM
Last Post: mcesmcsc
  How to copy files from subfolders into one folder silfer 3 5,233 Aug-29-2019, 08:36 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020