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
  Copy Paste excel files based on the first letters of the file name Viento 2 347 Feb-07-2024, 12:24 PM
Last Post: Viento
  Create new folders and copy files cocobolli 3 1,334 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Copy only hidden files and folders with rsync Cannondale 2 953 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  Search multiple CSV files for a string or strings cubangt 7 7,842 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,390 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  Search string in mutliple .gz files SARAOOF 10 6,775 Aug-26-2021, 01:47 PM
Last Post: SARAOOF
  how search files Ron_Crafter 4 42,158 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 1,760 Dec-09-2020, 05:14 PM
Last Post: sutra
  Copy files from subfolders into same name of subfolders at other directory rathoreanil 1 2,305 Oct-12-2020, 01:30 AM
Last Post: Larz60+
  need to define date range of files to copy over OTH 4 3,060 Aug-07-2020, 12:29 PM
Last Post: buran

Forum Jump:

User Panel Messages

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