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
  How to loop through all excel files and sheets in folder jadelola 1 802 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  is it possible to copy image from email and place into excel file? cubangt 3 414 Nov-30-2022, 05:11 PM
Last Post: snippsat
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 463 Nov-28-2022, 12:41 PM
Last Post: snippsat
  Please help me [copy and paste file from src to dst] midomarc 2 431 Nov-24-2022, 10:13 PM
Last Post: midomarc
  multiprocessing phash from every frame in folder flash77 12 856 Nov-20-2022, 02:33 PM
Last Post: flash77
  python gzip all files from a folder mg24 3 764 Oct-28-2022, 03:59 PM
Last Post: mg24
  delete all files and subdirectory from a main folder mg24 7 657 Oct-28-2022, 07:55 AM
Last Post: ibreeden
  python logger help ... save logger into different folder mg24 1 380 Oct-25-2022, 03:04 PM
Last Post: snippsat
  Merge all json files in folder after filtering deneme2 10 954 Sep-18-2022, 10:32 AM
Last Post: deneme2
  Function not executing each file in folder mathew_31 9 973 Aug-22-2022, 08:40 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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