Moving Files and Folders To Another Directory

Adejoke Ogundipe
2 min readJun 15, 2021

--

Are you tired of doing manual method of moving your projects or folders from one directory to another. Then you are in the right place.

It is my pleasure walking you through the approach I used.

Problem: Moving folders from one directory to another without doing copy and paste yourself.

This write up is to guide you through creating of folders, moving folders and files with a python script and as a bonus “deleting of directories”.

The steps to follow includes:

1: Importation of libraries as always.

the libraries used in this project.

2. Navigate to the paths where the folders or files you want to move or copy are, likewise the path where you want to move or copy them to.

3.Loop through the root, directories, files in the path

The last part of the image above shows the execution time of the project in seconds.

I moved the files in the folders first and create the folder names in another directory dynamically with the first 3 strings of the folder’s name and save the initial folders with the files in it.

The folders created with the first 3 strings of the main folder.
The main folder already moved to the specified path.
The file in the folder.

Thanks for your time out here and for leaning with me. For more, stay connected.

Thanks.

--

--

Adejoke Ogundipe
Adejoke Ogundipe

Written by Adejoke Ogundipe

Tech innovator, finance strategist, and growth enthusiast—exploring ideas, building solutions, and inspiring change.

No responses yet