How to move files in a folder and its sub-directory folders to a target folder in Python

How to move files in a folder and its sub-directory folders to a target folder in Python

Jie Jenn

5 лет назад

27,739 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@dustonmeyer3770
@dustonmeyer3770 - 16.09.2023 02:22

I have a folder full of .jpg files how do I move 25 randomly selected .jpgs from the folder and move them into a new folder "I want it to automatically create the folder when i automate the move" and have it repeat until all the files have been moved from the source folder. Thanks

Ответить
@angelaepakalibimbi210
@angelaepakalibimbi210 - 03.01.2023 20:23

I have a problem I have installed pil in pydroid now I want to know how to import PNG files into pil please help I am a beginner so I can open images

Ответить
@wakkiephone
@wakkiephone - 14.12.2022 14:30

Hi, can you guide me if I want to move files from different locations into one location?

Ответить
@pravindoke
@pravindoke - 10.12.2022 16:36

How can I do reverse of this process.. I have number of files and I want to create folders

Ответить
@BySixa
@BySixa - 21.10.2022 02:10

Thank you Jie.
Out of curiosity, why does your file path work with \ and mine only works with /. Is there a reason for this?
Again, thank you! really helped with my understanding of implementing os.walk

Ответить
@markmcfadden7428
@markmcfadden7428 - 27.07.2022 18:08

Thanks that was a very useful vid

Ответить
@peddinenivinitha5076
@peddinenivinitha5076 - 30.06.2022 13:58

can u please write a code for move subfolders to specified folder with files

Ответить
@annietrinh1452
@annietrinh1452 - 09.08.2021 10:04

what if i have 3 sub-folders in 1 parent folder and i only want select files from only 1 sub-folders to other folder? Something like Main folder 1- Kid Cloth | Inside this parent folder is thousand of sub-folder as 1.1-socer blue shirt; 1.2-socer yellow shirt; 1.3-socer white shirt....1.1000-socer colorful shirt---> and inside each of this sub-folder is 3 other sub-folder as 1.1.1-main photo; 1.1.2-detail page photo; 1.1.3-variations photos. Now i want to select all image file only from sub-folder 1.1.3-variations photos to 1 other Folder....and it from thousand of other sub-folder. What can I do?

Ответить
@ramyainchara5350
@ramyainchara5350 - 07.05.2021 14:25

Could you please help me to write a code to remove empty subfolders after copying all files into the parent directory ?. You have written code to move files, so, I want to remove empty folders.

Ответить
@rockrollandfunk2691
@rockrollandfunk2691 - 12.01.2021 02:49

Question, (the code and this video have been of real help) can I set 'file' to file = "ReadCMI" which is a file?!

Ответить
@alfredingram1280
@alfredingram1280 - 30.10.2020 21:44

Thank you Jie - very useful!

Ответить
@EtBukaneluu
@EtBukaneluu - 25.10.2020 02:06

I don't understand why you are typing
if file: <-
the statement for the 'if' it's not like the ones I've learned

Ответить
@JecasaLtd
@JecasaLtd - 10.09.2020 17:17

You are the master on this! Keep up the good work!

Ответить
@rinkiyadav2591
@rinkiyadav2591 - 15.08.2020 11:12

sir when we use shutil move then this error shows how can close this file before move plz reply
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '20200814124216.wav'

Ответить
@bingqingzhu2701
@bingqingzhu2701 - 12.04.2019 09:08

why we should add '\\' at the end of the file path?

Ответить