This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Python script for bulk renaming files in a specified directory | |
// How to use: | |
// python bulk_renamer.py /path/to/directory new_name_prefix --extension .txt --start 1 | |
// Renames .txt files as new_name_prefix1.txt, new_name_prefix2.txt, etc. | |
// If --extension is omitted, it renames all files. | |
// Modify the prefix to customize filenames. | |
import os | |
import argparse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def replace_text_in_file(file_path, search_text, replace_text, edited_lines): | |
try: | |
with open(file_path, 'r', encoding='utf-8', errors='ignore') as file: | |
lines = file.readlines() | |
modified = False | |
new_lines = [] | |
for i, line in enumerate(lines): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fitz # PyMuPDF | |
from docx import Document | |
from docx.shared import Pt | |
from docx.enum.text import WD_ALIGN_PARAGRAPH | |
def extract_text_from_pdf(pdf_path, pages=None): | |
document = fitz.open(pdf_path) | |
text = [] | |
if pages is None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def html_table_to_excel(html_file, output_excel_file): | |
try: | |
# Read the HTML file and extract all tables | |
tables = pd.read_html(html_file) | |
# Create a Pandas Excel writer using openpyxl | |
with pd.ExcelWriter(output_excel_file, engine='openpyxl') as writer: | |
# Loop through each table found in the HTML |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.edge.service import Service | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
import time | |
webdriver_service = Service('Path to \msedgedriver.exe') | |
driver = webdriver.Edge(service=webdriver_service) | |
driver.get("https://sitetorefresh.com") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cx_Oracle | |
import pandas as pd | |
import smtplib | |
import os | |
from email.message import EmailMessage | |
# Database Connection Details | |
DB_CONNECTION_STRING = "add connection string here" | |
# Email Configuration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the services to monitor | |
$servicesToCheck = @("service1", "service2", "service3") | |
# Define the path for the log file | |
$logFilePath = "C:\Logs\errorlog_services.txt" | |
foreach ($service in $servicesToCheck) { | |
$serviceStatus = Get-Service $service | Select-Object Status, DisplayName | |
$recipients = 'recipient@mail.com','recipient2@mail.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PowerShell script to check network connectivity and send email alerts if servers are not reachable | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
# The servers to check for | |
$serverNames = @("server1", "server2", "server3", "server4") | |
# Email settings | |
$recipients = 'mail1@ofrecipient.com','mail2@ofrecipient.com','mail3@ofrecipient.com' # Replace with the actual recipient email addresses | |
$from = "sender@mail.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import zipfile | |
# Function to unzip all files in the current directory | |
def unzip_files_in_directory(password): | |
# Get the directory where the script is located | |
script_directory = os.path.dirname(os.path.realpath(__file__)) | |
# List all files in the directory | |
files = os.listdir(script_directory) |
NewerOlder