Skip to content

Commit

Permalink
3.0.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Fern-Aerell committed Feb 19, 2023
1 parent 1761a5d commit 016c22c
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

Semua Perubahan Dan Penambahan Feature Ada Di Sini.

## 3.0.0 - 19/02/2023

### New UI

- Sekarang program ini memiliki ui sendiri.
![](images\gui1.PNG)


### Add Features
- Sekarang kita bisa mengatur cara kerja program ini untuk mengscan suatu folder, dengan mengubah beberapa peraturan ini.
![](images\gui2.PNG)

- Sekarang kita bisa membuka folder hasil hanya dengan menekan tombol tertentu.


### Remove Features
- Menghapus fitur scan folder yang lama.

---------------------------------------------------------------------------
## 2.0.0 - 15/02/2023

### Scan Folder (New)
Expand Down
Binary file added images/gui1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gui2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
appName = "Excel Project"
appVersion = "3.0.0 Release"
13 changes: 13 additions & 0 deletions excel_project.py → src/excel_project(deprecated).py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import shutil

def read_folder(folder, depth, folder_nama):
"""
@deprecated: Function telah usang.
"""
list_of_files = os.listdir(folder)
print(list_of_files)
for file in list_of_files:
Expand All @@ -15,11 +18,17 @@ def read_folder(folder, depth, folder_nama):
read_folder(file_path, depth + 1, folder_nama + ", " + file)

def write_file(file_name):
"""
@deprecated: Function telah usang.
"""
with open(file_name, 'w') as f:
f.write("".join(content))
print("File written: " + file_name)

def main_menu():
"""
@deprecated: Function telah usang.
"""
os.system('cls' if os.name == 'nt' else 'clear')
print("=======================================")
print("= Excel Project : Create By AerellDev =")
Expand Down Expand Up @@ -49,6 +58,7 @@ def main_menu():
if not os.path.exists(folder_nama):
os.makedirs(folder_nama)
print("Membuat folder Hasil...")

#2. Membuat Folder Baru Sesuai Nama Folder Asli Pada Folder Hasil
print("Membuat Folder " + folder_asal_split[-1])
os.makedirs("Hasil\\" + folder_asal_split[-1])
Expand Down Expand Up @@ -130,6 +140,9 @@ def main_menu():
main_menu()

def scan_folder_and_file_tree(folder_asal):
"""
@deprecated: Function telah usang.
"""
try:
content.clear()
read_folder(folder_asal, 0, folder_asal)
Expand Down
7 changes: 7 additions & 0 deletions src/excel_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ui import gui

#Kode Yang Akan Di Eksekusi Saat Program Di Jalankan.
def excel_project():
gui

excel_project()
118 changes: 118 additions & 0 deletions src/logic/scan_folder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import os
import shutil

def ScanFolder(folder_asal, read_file, copy_folder, detect_epub, change_name_file):
os.system('cls' if os.name == 'nt' else 'clear')
content = []
print("Scan Folder Is Running...")
try:

folder_asal_split = folder_asal.split(sep="/")
folder_asal_split = folder_asal.split(sep="\\")

if copy_folder:
#2. Membuat Folder Baru Sesuai Nama Folder Asli Pada Folder Hasil
try:
print("Membuat Folder " + folder_asal_split[-1])
os.makedirs("Hasil\\" + folder_asal_split[-1])
folder_hasil = "Hasil\\" + folder_asal_split[-1]
except:
print("Error : Gagal Membuat Folder " + folder_asal_split[-1])

# 3. Mengcopy Semua File Pada Folder Asli Ke Folder Hasil
try:
print("Mengcopy semua file pada folder " + folder_asal + " ke " + folder_hasil)
daftar_file_pada_folder_asal = os.listdir(folder_asal)
for file in daftar_file_pada_folder_asal:
file_path = os.path.join(folder_asal, file)
if os.path.isfile(file_path):
shutil.copy(file_path, folder_hasil)
except:
print("Error : Gagal mengcopy semua file pada folder " + folder_asal + " ke " + folder_hasil)
else:
folder_hasil = folder_asal

# Ketika Ada File Epub
#4. Membaca Semua File Pada Folder Hasil
try:
print("Membaca file yang ada di folder " + folder_hasil)
daftar_file_pada_folder_hasil = os.listdir(folder_hasil)
except:
print("Error : Gagal file yang ada di folder " + folder_hasil)

if detect_epub:
#5. Mendeteksi File Epub Pada Folder Hasil
try:
ada_file_epub = False
print("Mendeteksi file epub")
for file in daftar_file_pada_folder_hasil:
if '.epub' in file:
ada_file_epub = True
print("Ada file epub : " + file)
break
else:
print("Tidak ada file epub")
ada_file_epub = False
if ada_file_epub:
#6. Memindahkan file epub ke folder terpisah
#7. Membuat Folder Epub
os.makedirs(folder_hasil + "\\epub")
#8. Memindahkan File Epub Ke Folder Epub
for file in daftar_file_pada_folder_hasil:
if '.epub' in file:
shutil.move(folder_hasil + "\\" + file, folder_hasil + "\\epub\\" + file)
except:
print("Error : Gagal mendeteksi file epub")

# Lanjutan
#9. Membaca Semua File Pada Folder Hasil
try:
print("Membaca file yang ada di folder " + folder_hasil)
daftar_file_pada_folder_hasil = os.listdir(folder_hasil)
except:
print("Error : Gagal membaca file yang ada di folder " + folder_hasil)

if read_file:
#10. Menyimpan Hasil Bacaan Pada Folder Hasil dengan nama file "Nama File Pdf.txt"
try:
print("Menyimpan hasil nya pada file Nama" + folder_hasil + "\File PDF.txt")
for file in daftar_file_pada_folder_hasil:
file_path = os.path.join(folder_hasil, file)
if os.path.isfile(file_path):
content.append(file + "\n")
file_nama = "Nama File PDF.txt"
with open(folder_hasil + "\\" + file_nama, 'w') as f:
f.write("".join(content))
print("File written: " + file_nama)
except:
print("Error : Gagal menyimpan hasil nya pada file Nama" + folder_hasil + "\File PDF.txt")

if change_name_file:
#11. Mengubah Semua Nama File Pada Folder Hasil Menjadi Ada Angka Nya Sebelum Nama File nya, Contoh "1_Buku guru.pdf"
try:
print("Mengubah semua nama file pada folder " + folder_hasil)
start_num = 0
for i, file_name in enumerate(daftar_file_pada_folder_hasil):
file_path = os.path.join(folder_hasil, file_name)
if os.path.isfile(file_path):
old_path = os.path.join(folder_hasil, file_name)
new_name = f"{start_num + 1}_{file_name}"
new_path = os.path.join(folder_hasil, new_name)
os.rename(old_path, new_path)
start_num += 1
except:
print("Error : Gagal mengubah semua nama file pada folder " + folder_hasil)

#12. Membaca Lagi Semua File Pada Folder Hasil
try:
print("Membaca file yang ada di folder " + folder_hasil)
daftar_file_pada_folder_hasil = os.listdir(folder_hasil)
except:
print("Error : Gagal membaca file yang ada di folder " + folder_hasil)

#13. Program Selesai
print("Scan Folder Selesai...")
content.clear()
except:
print("Scan Folder Selesai...")
content.clear()
48 changes: 48 additions & 0 deletions src/ui/gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import PySimpleGUI as gui
import config
from utils import utils
import os
from logic import scan_folder

#Setup
utils.buatFolderJikaTidakAda("Hasil")

#Set Theme
gui.theme("SystemDefault")

#Create Window Content
layout = [
[gui.Text("Scan folder"), gui.Input(key="-FOLDER-", size=[52]), gui.FolderBrowse()],
[gui.Checkbox("Membaca semua nama file dalam folder dan menyimpan nya", key="-READ-FILE-", default=True)],
[gui.Checkbox("Copy folder Ke Folder Hasil", key="-OPSI-COPY-FOLDER-", default=True)],
[gui.Checkbox("Mendeteksi file epub dan memisahkannya", key="-DETECT-EPUB-FILE-", default=True)],
[gui.Checkbox("Mengubah dan menambahkan angka pada nama file", key="-CHANGE-NAME-FILE-", default=True)],
[gui.Output(size=(70, 10), key='-OUTPUT-')],
[gui.Button("Scan Folder", size=(30)), gui.Button("Buka Folder Hasil", size=(31))]
]

#Create Window
window = gui.Window(config.appName + " - " + config.appVersion, layout)

# Display and interact with the Window
while True:
event, values = window.read()

folder_yang_discan = values["-FOLDER-"]
read_file = values["-READ-FILE-"]
copy_folder = values["-OPSI-COPY-FOLDER-"]
detect_epub = values["-DETECT-EPUB-FILE-"]
change_name_file = values["-CHANGE-NAME-FILE-"]

if event == gui.WIN_CLOSED:
break
if event == "Scan Folder":
if os.path.exists(folder_yang_discan):
scan_folder.ScanFolder(folder_yang_discan, read_file, copy_folder, detect_epub, change_name_file)
else:
print("Folder Tidak Ada")
if event == "Buka Folder Hasil":
utils.bukaFolder("Hasil")


window.close()
8 changes: 8 additions & 0 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os

def buatFolderJikaTidakAda(folder_nama):
if not os.path.exists(folder_nama):
os.makedirs(folder_nama)

def bukaFolder(folder_nama):
os.startfile(folder_nama)

0 comments on commit 016c22c

Please sign in to comment.