Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
blahpr authored Sep 25, 2024
1 parent 78585dc commit 08a967a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
27 changes: 23 additions & 4 deletions D.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -399,33 +399,52 @@ class FileOrganizerApp:

def simplify_name(self, filename, options):
name, ext = os.path.splitext(filename)

# Remove special characters if the option is enabled
if options['remove_special']:
name = re.sub(r'[^\w\s.-]', '', name)

# Replace underscores with spaces if the option is enabled
if options['replace_underscore']:
name = name.replace('_', ' ')

# Replace dots, but preserve dots within numbers (e.g., version numbers)
if options['replace_dot']:
# Keep periods within numbers, replace only other periods
name = re.sub(r'(?<!\d)\.(?!\d)', ' ', name)
# Replace dots between words, but keep dots within numbers (e.g., "v1.0")
# Also remove dots after letters and before numbers or other letters (e.g., "Plus.26" -> "Plus 26")
name = re.sub(r'(?<=[a-zA-Z])\.(?=\d)', ' ', name) # Handles "Plus.26" -> "Plus 26"
name = re.sub(r'(?<=\d)\.(?=[a-zA-Z])', ' ', name) # Handles dots between numbers and letters
name = re.sub(r'(?<!\d)\.(?!\d)', ' ', name) # Replace other dots with spaces except between numbers

# Remove extra spaces if the option is enabled
if options['remove_double_spaces']:
name = re.sub(r'\s+', ' ', name)

# Replace hyphens with spaces if the option is enabled
if options['remove_hyphen']:
name = name.replace('-', ' ')
# Add a space before uppercase letters that follow lowercase letters, but only if the checkbox is selected

# Add a space before uppercase letters that follow lowercase letters, if the option is enabled
if self.add_space_before_uppercase_var.get():
name = re.sub(r'(?<=[a-z])(?=[A-Z])', ' ', name)
# Add a space between numbers and letters

# Add a space between numbers and letters if the option is enabled
if options['remove_double_spaces']:
name = re.sub(r'(?<=\d)(?=[A-Za-z])', ' ', name)

# Optional: Add space after periods if followed by letters (e.g., "360.Utility" -> "360 Utility")
if options['replace_dot']:
name = re.sub(r'\.(?=[A-Za-z])', ' ', name)

# Replace hyphens and other separators with spaces
if options['remove_hyphen']:
name = re.sub(r'[^\w\s\.]', ' ', name)

# Remove extra spaces (redundant, but ensures clean output)
if options['remove_double_spaces']:
name = re.sub(r'\s+', ' ', name)

# Return the modified name along with the original file extension
return f"{name.strip()}{ext}"

def load_data(self):
Expand Down
3 changes: 2 additions & 1 deletion Setup.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@echo off
pyinstaller --onefile --icon=images\D.ico --name="Text Right v1.0" --distpath="Text Right v1.0" --add-data="images;images" --add-data "C:\Users\Bobzer\AppData\Local\Programs\Python\Python312\Lib\site-packages\tkdnd\tkdnd\win64;tkdnd" --upx-dir "C:\upx-4.2.4-win64" D.pyw
pyinstaller --onefile --icon=images\D.ico --name="Text Right v1.0" --distpath="Text Right v1.0" --add-data="images;images" --add-data "C:\Users\Bobzer\AppData\Local\Programs\Python\Python312\Lib\site-packages\tkdnd\tkdnd\win64;tkdnd" --upx-dir "C:\upx-4.2.4-win64" D.pyw
"C:\upx-4.2.4-win64\upx.exe" --brute --force "Text Right v1.0\Text Right v1.0.exe"
echo.
pause.

0 comments on commit 08a967a

Please sign in to comment.