I have a lot of files in /home/somedir/subdir/ and I\'m trying to move them all up to /home/somedir programmatically.
right now I have this:
subprocess.c
Here's a simple way to work with subprocess Popen
import subprocess
import os
class FolderCommands:
src = None
dst = None
def __init__(self, src, dst):
self.src = src
self.dst = dst
def move(self):
listOfFiles = os.listdir(self.src)
print(listOfFiles)
modify_src = self.src.replace(" ", "\ ")
dst = self.dst.replace(" ", "\ ")
for f in listOfFiles:
#Attaching the filename at the end of the src path
fullPath = modify_src + "/'" + f +"'"
subprocess.Popen("mv" + " " + fullPath + " " + dst, shell=True)
obj = FolderCommands(input("Enter Source path"), input("Enter Destination path"))
obj.move()