add files
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
#list files
|
||||
import os
|
||||
import pathlib
|
||||
from pathlib import Path
|
||||
|
||||
#variables
|
||||
|
||||
#directories_path = r'C:\Users\pgeeraert\OneDrive - Prometheus Group\Documents\Code\Duplicator_lister\folder'
|
||||
|
||||
directories_path = r'C:\Users\pgeeraert\Downloads\OneDrive_2024-07-31\photo upload'
|
||||
|
||||
class bcolors:
|
||||
HEADER = '\033[95m'
|
||||
OKBLUE = '\033[94m'
|
||||
OKCYAN = '\033[96m'
|
||||
OKGREEN = '\033[92m'
|
||||
WARNING = '\033[93m'
|
||||
FAIL = '\033[91m'
|
||||
ENDC = '\033[0m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
|
||||
|
||||
#code
|
||||
print("this is the path : "+directories_path)
|
||||
entries = os.listdir(directories_path)
|
||||
#print(entries)
|
||||
|
||||
|
||||
|
||||
basepath = directories_path
|
||||
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# list of files
|
||||
#
|
||||
#########################################################
|
||||
# Define a function to list all files in a directory recursively
|
||||
def list_files(dir_path):
|
||||
# Initialize a list to store the file paths
|
||||
files = []
|
||||
|
||||
# Iterate over all the directories and files in the given directory
|
||||
for dirpath, dirnames, filenames in os.walk(dir_path):
|
||||
# Iterate over each file in the current directory
|
||||
for filename in filenames:
|
||||
# Append the file path to the list
|
||||
files.append(os.path.join(dirpath, filename))
|
||||
|
||||
# Return the list of file paths
|
||||
return files
|
||||
|
||||
# Call the function to list all files in the current directory and its subdirectories
|
||||
files = list_files(basepath)
|
||||
|
||||
# Print the list of files
|
||||
for file in files:
|
||||
print(file)
|
||||
|
||||
|
||||
import os
|
||||
|
||||
#########################################################
|
||||
#
|
||||
# list of files and sort them
|
||||
#
|
||||
#########################################################
|
||||
|
||||
|
||||
# Define a function to list all files in a directory recursively
|
||||
def list_files_with_names(dir_path):
|
||||
# Initialize a list to store the file paths and names
|
||||
files = []
|
||||
|
||||
# Iterate over all the directories and files in the given directory
|
||||
for dirpath, dirnames, filenames in os.walk(dir_path):
|
||||
# Iterate over each file in the current directory
|
||||
for filename in filenames:
|
||||
# Append the file path and name to the list
|
||||
files.append({
|
||||
"filename": filename,
|
||||
"full_path": os.path.join(dirpath, filename)
|
||||
})
|
||||
|
||||
# Return the list of file paths and names
|
||||
return files
|
||||
|
||||
def find_duplicates_in_list(filename_input,file_fullpath_input,list_input):
|
||||
for file in list_input:
|
||||
if(filename_input==file['filename'] and file['full_path']!=file_fullpath_input):
|
||||
print(bcolors.FAIL + "Duplicate found: present here "+file_fullpath_input+" and here: "+file['full_path']+ bcolors.ENDC)
|
||||
|
||||
|
||||
# Call the function to list all files in the current directory and its subdirectories
|
||||
files = list_files_with_names(basepath)
|
||||
|
||||
# Print the list of files with their names and full paths
|
||||
for file in files:
|
||||
print(f"Filename: {file['filename']}, Full Path: {file['full_path']}")
|
||||
find_duplicates_in_list(file['filename'],file['full_path'],files)
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
from nicegui import ui
|
||||
import random
|
||||
|
||||
image_to_delete = ['image1']
|
||||
|
||||
print(image_to_delete)
|
||||
|
||||
def mark_image_as_to_delete(image_to_add_fullname,images_to_delete_list_input):
|
||||
images_to_delete_list_input.append(image_to_add_fullname)
|
||||
|
||||
def add_number() -> None:
|
||||
numbers.append(random.randint(0, 100))
|
||||
number_ui.refresh()
|
||||
|
||||
numbers = []
|
||||
|
||||
@ui.refreshable
|
||||
def number_ui() -> None:
|
||||
ui.label(', '.join(str(n) for n in numbers))
|
||||
|
||||
def add_number() -> None:
|
||||
numbers.append(random.randint(0, 100))
|
||||
number_ui.refresh()
|
||||
|
||||
def add_name(name_input) -> None:
|
||||
numbers.append(name_input)
|
||||
number_ui.refresh()
|
||||
|
||||
@ui.refreshable
|
||||
def image_to_delete_ui() -> None:
|
||||
ui.label(', '.join(str(n) for n in image_to_delete)).classes('w-1/2 absolute-top-right')
|
||||
|
||||
def add_image_to_delete(image_to_add_fullname) -> None:
|
||||
image_to_delete.append(image_to_add_fullname)
|
||||
image_to_delete_ui.refresh()
|
||||
"""
|
||||
def clear_list_image_to_delete() -> None:
|
||||
image_to_delete.clear()
|
||||
image_to_delete_ui.refresh()
|
||||
"""
|
||||
|
||||
mark_image_as_to_delete('image2',image_to_delete)
|
||||
|
||||
print(image_to_delete)
|
||||
|
||||
duplicate_list=[{
|
||||
"source": 'duplicator/20150820_154915.jpg',
|
||||
"destination": 'duplicator/IMG_1084.JPG'
|
||||
}]
|
||||
duplicate_list.append({
|
||||
"source": 'duplicator/20150621_123524.jpg',
|
||||
"destination": 'duplicator/20150820_154907.jpg'
|
||||
})
|
||||
print(duplicate_list)
|
||||
|
||||
for image in duplicate_list:
|
||||
"""
|
||||
with ui.splitter() as splitter:
|
||||
with splitter.before:
|
||||
#image_to_delete_ui()
|
||||
#ui.button('Add delete button', on_click=add_image_to_delete(image['source']))
|
||||
#ui.label(image_to_delete)
|
||||
ui.label("path: "+image['source']).classes('mr-2')
|
||||
ui.image(image['source'])
|
||||
ui.button('mark as removed', on_click=mark_image_as_to_delete(image['source'],image_to_delete))
|
||||
with splitter.after:
|
||||
#image_to_delete_ui()
|
||||
number_ui()
|
||||
ui.button('Add random number', on_click=add_number)
|
||||
ui.button('Add delete button', on_click=add_name(image['destination']))
|
||||
ui.label(image['destination']).classes('ml-2')
|
||||
ui.image(image['destination'])
|
||||
ui.button('mark as removed', on_click=mark_image_as_to_delete(image['destination'],image_to_delete))
|
||||
"""
|
||||
with ui.splitter().classes('w-full h-96') \
|
||||
.props('before-class=overflow-hidden after-class=overflow-hidden') as splitter:
|
||||
with splitter.before:
|
||||
# ui.skeleton().classes('w-1/2 absolute-top-right')
|
||||
image_to_delete_ui()
|
||||
ui.button('Add delete button', on_click=add_image_to_delete(image['source']))
|
||||
#ui.button('clear button', on_click=clear_list_image_to_delete())
|
||||
with ui.card().tight():
|
||||
ui.image(image['source'])
|
||||
with ui.card_section():
|
||||
ui.label("path: "+image['source'])
|
||||
|
||||
|
||||
# ui.label("path: "+image['source']).classes('w-1/2 absolute-top-right')
|
||||
# ui.image(image['source']).classes('w-1/2 absolute-top-left')
|
||||
with splitter.after:
|
||||
number_ui()
|
||||
ui.button('Add random number', on_click=add_number)
|
||||
with ui.card().tight():
|
||||
ui.image(image['destination'])
|
||||
with ui.card_section():
|
||||
ui.label("path: "+image['destination'])
|
||||
|
||||
# ui.label("path: "+image['destination']).classes('w-1/2 absolute-top-left')
|
||||
# ui.image(image['destination']).classes('w-1/2 absolute-top-right')
|
||||
|
||||
|
||||
|
||||
ui.run()
|
||||
Reference in New Issue
Block a user