Skip to content

Instantly share code, notes, and snippets.

View Edwardtonnn's full-sized avatar
🎯
Focusing

Edward Edwardtonnn

🎯
Focusing
  • Los Angeles Web Club
  • South Gate, CA
View GitHub Profile
@Edwardtonnn
Edwardtonnn / renameImages.bash
Created April 15, 2024 17:23
Renames all images in the directory 01.jpg 02.jpg 03.jpg
cmd /v:on /c "set i=0 & for %f in (*.jpg) do (set /a i+=1 & set "num=00!i!" & set "num=!num:~-2!" & ren "%f" "!num!.jpg")"
@Edwardtonnn
Edwardtonnn / gallery.scss
Last active April 4, 2024 16:45
Alt Gallery SCSS
@Edwardtonnn
Edwardtonnn / rename.ps1
Created February 26, 2024 22:05
rename all images in all folders 01 02 03 etc in
Get-ChildItem -Directory | ForEach-Object {
$Folder = $_
$i = 1
Get-ChildItem $Folder -File | ForEach-Object {
$NewName = "{0:D2}.jpg" -f $i++
# Check if the file is already named correctly
if ($_.Name -ne $NewName) {
$NewPath = Join-Path $Folder.FullName $NewName
# Check if a file with the new name already exists to avoid overwriting
if (-Not (Test-Path $NewPath)) {
@Edwardtonnn
Edwardtonnn / index.html
Created February 9, 2024 19:07
emmet for using the same value
option[value=$#]*>{$#}
@Edwardtonnn
Edwardtonnn / delete.py
Created January 11, 2024 22:34
Python script to search a dirctory of galleries to find an even number of images. If dir does not have an even number of images it deletes the last one. The idea behind this script was to find trash images since before and after are always even.
import os
import glob
# Replace this with your directory path
base_directory = "./body/corrective-body-contouring/"
# Loop through each folder in the directory
for folder in os.listdir(base_directory):
folder_path = os.path.join(base_directory, folder)
@Edwardtonnn
Edwardtonnn / duplicates.ps1
Created December 14, 2023 19:30
Removes duplicates from SEO Title
# Define the path to the root of your PHP projects
$rootPath = "./"
# Define the file pattern to search for
$filePattern = "*.php"
# Function to fix the SEO title in a file
function Fix-SeoTitle {
param (
[string]$filePath
@Edwardtonnn
Edwardtonnn / dir-to-json.py
Created December 11, 2023 22:45
Python script to output all dir into json file
import os
import json
# Specify the directory you want to search in
directory_path = "./"
# Function to list all folders in a directory
def list_folders(directory):
folder_list = []
for root, dirs, files in os.walk(directory):
@Edwardtonnn
Edwardtonnn / reverse-folders.ps1
Last active January 11, 2024 22:23
Reverses dir folder names. Used for gallery reversals. Paste into powershell and hit enter
# Get the list of directories in the current folder
$directories = Get-ChildItem -Directory | Sort-Object Name
# Temporary name for renaming
$tempName = "tempDir"
# Rename directories to temporary names in reverse order
for ($i = 0; $i -lt $directories.Count; $i++) {
$newName = "{0:D2}" -f ($directories.Count - $i)
Rename-Item $directories[$i].Name $tempName$newName
@Edwardtonnn
Edwardtonnn / renameInOrder.py
Created November 29, 2023 22:42
Renames all folders in numberic order 01 02 03...
import os
import sys
def rename_directories_to_sequential_numbers(path):
if not os.path.isdir(path):
print(f"The provided path '{path}' is not a valid directory.")
return
dirs = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]
dirs.sort()
@Edwardtonnn
Edwardtonnn / lower.py
Created November 22, 2023 15:04
To lowercase all lazy-src=""
import os
import re
# Function to lowercase everything within the 'lazy-src' attribute in an HTML file
def lowercase_lazy_src(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# Use regular expression to find all 'lazy-src' attributes and lowercase their values
modified_content = re.sub(r'lazy-src="([^"]+)"', lambda match: f'lazy-src="{match.group(1).lower()}"', content, flags=re.IGNORECASE)