Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 15 additions & 35 deletions file_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
newfileExt = []
newSet = set()
fullPath = ''
# getExistingDir = ''

if currentDirectory != chgeDirectory:
os.chdir(chgeDirectory)
Expand Down Expand Up @@ -79,17 +78,15 @@
os.mkdir(uniqFile) # .title())
print(f"{uniqFile} created successfully")
except FileExistsError:
print(f"{uniqFile} already exists ")
print(f"{uniqFile} folder already exists ")

for vryFile in lstDir:
# print(vryFile)

if os.path.isfile(vryFile):
fullPath = os.path.join(chgeDirectory, vryFile)
# print(f"{fullPath}, read this first")

for chkFolder in folderSide:
# print(chkFolder)

getExistingDir = os.path.join(chgeDirectory, chkFolder)

try:
Expand All @@ -99,50 +96,33 @@
if word in fullPath and word in getExistingDir:
print(shutil.move(fullPath, getExistingDir))

elif os.path.isfile(vryFile) and vryFile in getExistingDir:
print(f"{vryFile}, I am printing this")
# elif os.path.isfile(vryFile) and vryFile in getExistingDir:
# print(f"{vryFile}, I am printing this")

# elif vryFile in getExistingDir:
# print(f"{vryFile} already exists in directory")
except shutil.Error:
print(f"{vryFile} file already exits")

# A new code begins from here. Everything works well from here until adding new code to it
# A new code begins from here. The code above works well and adding new code below

# Check if the file or folder already exits
# dirPath = os.path.join(chgeDirectory, lstDir)
# for read in os.listdir():
# getdirfullpathName = os.path.join(chgeDirectory, read)
# print(getdirfullpathName)
# # if
# os.wal

dirCheck = r'C:\Users\admin\Downloads'

# print(folderSide)
# dirCheck = r'C:\Users\admin\Downloads'

# for ck in fileSide:
#
# if os.path.isfile(ck):
# print(ck)
# if os.path.isfile():

# print(ck)
print(chgeDirectory)

getFileName = ''

# for roots, dirs, files in os.walk(chgeDirectory): # ".", topdown=True):
# # print(roots)

for fileCheck in lstDir:
if os.path.isfile(fileCheck):
getFileName = fileCheck
print(f"{getFileName} this is for the loop")
getFileName += fileCheck

for name in lstDir:
dirPath = os.path.join(dirCheck, name)
print(dirPath)
dirPath = os.path.join(chgeDirectory, name)
for roots, dirs, files in os.walk(dirPath):
if getFileName in files:

print(f"{getFileName} already exits in ", os.path.abspath(dirPath))
print(f"Removing {getFileName} in ", os.getcwd())
os.remove(getFileName)

# for data in dirPath:
# os.listdir(data)
# if