Exercise 7 - Clear the Clutter | Python Tutorial - Day #68

preview_player
Показать описание

python, C, C++, Java, JavaScript and Other Cheetsheets [++]:

►Learn in One Video[++]:

►Complete course [playlist]:

Follow Me On Social Media
Comment "#HarryBhai" if you read this 😉😉
Рекомендации по теме
Комментарии
Автор

Excercise 07 Done :)
import os

class ClearTheCulture:
def Create(self):
if (not os.path.exists("lala")):
os.mkdir("lala")
for i in range(0, 5):
os.mkdir(f"lala/sdahfhjk {i+1}")

def rename(self):
for i in range (0, 5):
os.rename(f"lala/sdahfhjk {i+1}", f"lala/1.png {i+1}")

obj = ClearTheCulture()
obj.Create()
#obj.rename()

azixkhan
Автор

All the chapters till I study was really awesome and all the content was in very friendly language . I really appreaciate this python FREE Course to all.. Thanku Harry sir

sureshsoni
Автор

Present sir on #Day68 and I actually on purpose skipped the course coz in the meantime I did a very useful project using python but now I'm really falling behind in the course

arpankarmakar
Автор

Thanks you, harry sir for this python course ❤

modratoryt
Автор

I missed 5 days of 100 days of coding
due to my exam and I'm still on day 63😞
Its getting harder🥵 each and every day

MunnaBhai
Автор

Day #57 of asking to make a discord server


Please support the campaign by liking this comment...

shaon
Автор

Harry Bhai it's a request that please add any digital certificate at the end of this 100 days of code, it is not hard for you and it will help us to add this types of achievements in our portfolio, it's an humble request
Thank you #codewithharry

steps.ofLife
Автор

import os
path=input("enter the floder path:")
path=path.replace('\\', '/')
print(path)
print(os.listdir(path))
def rename():
i=1
for filename in os.listdir(path):
new_name=path+"ghj"+str(i)
old_name=path+filename
os.rename(old_name, new_name)
i = i+1
rename()
sloution of exercise

MokshMishra
Автор

very simple solution:

import os
def create():
if(not os.path.exists("clear")):
os.mkdir("clear")

for i in range(0, 5):
os.mkdir(f"clear/hdkjs {i+1}")

def rename():
for i in range(0, 5):
os.rename(f"clear/hdkjs {i+1}", f"{i+1}.png")


# create()
rename()

boostcom
Автор

#100daysofcode
import os

image_folder = "exercise_7/"

if not
print("Folder not found.")
else:
print("Folder found:", image_folder)
i = 0
for filename in os.listdir(image_folder):
if
i += 1
new_filename = f"image_{i}.png"
old_path = os.path.join(image_folder, filename)
new_path = os.path.join(image_folder, new_filename)
os.rename(old_path, new_path)
print(f"Renamed {filename} to {new_filename}")

ayushkhaire
Автор

import os
def func(path, extention):
a=os.listdir(path)
new_name=1
for i in a:
if i.endswith("."+extention):
os.rename(path+"/"+i, path+"/"+str(new_name)+"."+extention)
new_name+=1

func("Files", "pdf")

kavyajain
Автор

import os
def clutter(files, dir, a):
count=1
for file in files:
if file.endswith(a):
new_name = str(count) + a
os.rename(os.path.join(dir, file), os.path.join(dir, new_name))
count+=1


dir=input("Enter Directory Of Files:")
files=os.listdir(dir)
a=input("Enter Your File Type:")
clutter(files, dir, a)

allyouinfotech
Автор

Day 68 of 100 of python challenge completed. #100DaysofCode #100dayspythonchallenge

lakhyadeepsen
Автор

import os

def organize(type):
listOfType = [file for file in os.listdir() if file.endswith(type)]

for index, item in enumerate(listOfType, start=1):
print(item)
os.rename(item, str(index) + type)

organize('.png')

# Done

lazyranger
Автор

# Name : Heet Mehta
import os
def clear(folder, extension):
os.chdir(folder)
i = 1
for f in os.listdir(folder):
if f.endswith(extension):
os.rename(f, f'{i}{extension}')
i += 1

if __name__ == '__main__':
clear(r'C:\Users\admin\Desktop\testfol', '.mp3')

adventuresofavalon
Автор

import os


files = os.listdir("New folder")
i=1

for file in files:
if file.endswith("jpg"):
folder\{file}", folder\{i}.jpg")
i=i+1
elif file.endswith("png"):
folder\{file}", folder\{i}.png")
i=i+1
elif file.endswith("txt"):
folder\{file}", folder\{i}.txt")
i=i+1
elif file.endswith("pdf"):
folder\{file}", folder\{i}.pdf")
i=i+1

print(files)

dhruvyaduvanshi
Автор

Hii Harry brother I made a square root quiz program in python please consider my code
import random
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
a=random.randint(1, 50)
print(a*a)
v= int(input('enter the square root of number above:'))
if v==a:
print('correct')
elif v!= a:
print('incorrect')
Thank you

ritamistry
Автор

import os

print(f"Current Directory: {os.getcwd()}")

os.chdir("c:\\pngfolder")



file_extensions=[]

count=1

for i in oslist:

    ostuple=os.path.splitext(i)

   

    for j in file_extensions:

        if (j=='.png'):

            try:

                os.rename(f"c:\\pngfolder\\{i}", f"c:\\pngfolder\\MyScreenshot_ {count}.png")

                count+=1

                print("name changed")

            except Exception as e:

                print(f"There is a problem in {i} file: {e}")

soumyajeetdas
Автор

Import os
def fun(path, extension)
New_name=0
For i in a:
If i.endswith("."+extension):
Os.rename(path+"/+i, path+"/"+str(new _name)+"."+extension)
New_name+=1
Fun("Files", "png")
Shoutout sir kabhi diya nahi

narendraade
Автор

import os
import random
def make():
os.makedirs("__test")
temp = ["hhfi", "uhfi", "hfej", "fhjf", "hjhf"]
for i in range(1, 16):
with open(f"__test\\{(random.choices(temp))}.txt", "w") as f:
f.write(f"This is test file number {i}")
def clutter():
tem = os.listdir("__test")
for i, name in enumerate(tem):
os.rename(f"__test\\{name}", f"__test\\test{i+1}.txt")
clutter()

codewithpratham
welcome to shbcf.ru