# Moe top 1 file to destination

Hi Team,
I am new to Python, i have a requirement to move only 1 file which is top in a source folder to destination folder in windows environment.

Thanks
Nag

I am new to Python, i have a requirement to move only 1 file which is
top in a source folder to destination folder in windows environment.

Well, the shutil module has a move() function for this purpose. You may
need to the functions in os.path (basename, dirname, join) to construct
the correct paths.

Also note that because Windows paths use backslahes ("") and the
backslash is an escape character in normal Python strings it it usually
best to use “raw” strings when writing Windows paths by starting the
string with the r’ prefix instead of just ', example:

>>> top_folder = r'C:\path\to\top\named\folder'
>>> top_folder
'C:\\path\\to\\top\\named\\folder'


The assignment is a nice clean way to write the Windows path. The
recitation below is what you would need to write if you were not using
“raw” strings - see the tedious doubling of the backslashes.

Cheers,
Cameron Simpson cs@cskk.id.au