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
  Help with creating folder and "virtual environment" AudunNilsen 1 171 Mar-21-2024, 04:41 AM
Last Post: deanhystad
Question How to add Python folder in Windows Registry ? Touktouk 1 206 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 348 Feb-07-2024, 12:24 PM
Last Post: Viento
  Create dual folder on different path/drive based on the date agmoraojr 2 378 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 466 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  What script to paste folders thenewcoder 1 639 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  problem in import module from other folder akbarza 5 1,260 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  Reading a file name fron a folder on my desktop Fiona 4 851 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Rename files in a folder named using windows explorer hitoxman 3 693 Aug-02-2023, 04:08 PM
Last Post: deanhystad
  Rename all files in a folder hitoxman 9 1,387 Jun-30-2023, 12:19 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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