Python Forum
Python Cut/Copy paste file from folder to another folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Cut/Copy paste file from folder to another folder
#1
I have bunch of PDFs that are reports generated by system named AR_00002755, AR_00002758, AR_00002760 ...so on etc.

I already have Folders named as 00002755, 00002758, 00002760 ...so on etc.

What i want to achieve is cut the PDF file "AR_00002755.pdf" and paste it inside Folder named "00002755"

My Folder at the moment looks like this:-

  1. Folder - 00002755
  2. Folder - 00002758
  3. Folder - 00002760
  4. AR_00002755.pdf
  5. AR_00002758.pdf
  6. AR_00002760.pdf


My end goal is, when I run the python script all the pdfs will go into their respective folders.
Reply
#2
Do you just mean that you want to move the files? Look at the shutil module.
Reply
#3
(Aug-19-2020, 11:48 AM)ndc85430 Wrote: Do you just mean that you want to move the files? Look at the shutil module.

Yes i want to move pdf from the current folder to the 'named' folder, i.e. move "AR_00002755.pdf" to folder named "00002755"
Reply
#4
Then my advice still stands.
Reply
#5
(Aug-19-2020, 12:01 PM)ndc85430 Wrote: Then my advice still stands.

I am reading shutil but i am unable to understand how to pick exactly the AR_00002755.pdf and put inside the folder named 00002755...

The only thing i got so far is i can move file 1,2,3, to another any folder but how exactly to folder named similar to PDF except few words either at beginning or at end??

In my case the words 'AR_' are present in PDFs but not in folder.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 228 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Deleting Windows temp folder Raysz 7 371 Apr-02-2024, 12:36 PM
Last Post: Raysz
  Help with creating folder and "virtual environment" AudunNilsen 1 210 Mar-21-2024, 04:41 AM
Last Post: deanhystad
Question How to add Python folder in Windows Registry ? Touktouk 1 236 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Copy Paste excel files based on the first letters of the file name Viento 2 406 Feb-07-2024, 12:24 PM
Last Post: Viento
  Create dual folder on different path/drive based on the date agmoraojr 2 423 Jan-21-2024, 10:02 AM
Last Post: snippsat
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 522 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  What script to paste folders thenewcoder 1 660 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  problem in import module from other folder akbarza 5 1,380 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  Reading a file name fron a folder on my desktop Fiona 4 889 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

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