Hack Forums
[Python] Moving a file in python using shutil - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Moving a file in python using shutil (/showthread.php?tid=2143765)



Moving a file in python using shutil - Needlz - Jan 24, 2012

Hi, I am currently learning python 3 and needed to learn how to move a file for a script I am currently making.

I have commented so you know what is going on. I am using the shutil module and getting user input.

This is written for py3

Quote:#Importing the shutil module
import shutil

#Asking user input for the source file
source = input("Please enter your source file > ")

#Asking user input for destination
destination = input("Now please enter your destination file > ")

#Moving the source to destination =
shutil.move(source, destination)

print (" ")
print ("Your file was moved to ", destination)




* - Hydra_ - Jan 24, 2012

the script is working good buddy ,,, and there is no problem in it ... what do u need ???


* - Needlz - Jan 24, 2012

(Jan 24, 2012 05:03 PM)The-Hydra Wrote:  the script is working good buddy ,,, and there is no problem in it ... what do u need ???

Don't need anything was just posting it up to help other users


* - Hydra_ - Jan 24, 2012

(Jan 24, 2012 05:07 PM)Needlz Wrote:  Don't need anything was just posting it up to help other users

ahaaa ... sorry 😁

but, don't u see it's kinda little thread ... i mean u can put many other things in addition to this ... and you are a LEET so u can Edit ur thread any time 🙂 ... just my opinion ✌


* - Rhynorater. - Jan 24, 2012

This has already been posted. But a nice contribution non the less.

-Rhynorater.


* - dsMadKilla11 - May 27, 2012

Pretty neat script.Kind of less interactive though for the user has to input the directory.
It may have been better if you had stored it as a variable or passed it as a parameter of a function.(I'm gonna try a bit more)