Skip to content

Instantly share code, notes, and snippets.

@robes7
robes7 / Bulk_renamer.py
Created February 16, 2025 14:33
Bulk file renamer
// 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
@robes7
robes7 / File_text_replacer.py
Created February 15, 2025 12:25
File text replacer
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):
@robes7
robes7 / Upload_file_to_sharepoint.py
Created February 15, 2025 12:24
Upload file to a Sharepoint
import requests
import json
from requests_ntlm import HttpNtlmAuth
def upload_file_to_sharepoint():
# User-specific configurations (replace with actual values)
site_url = "https://yourcompany.sharepoint.com/sites/your-site"
folder_url = "/sites/your-site/your-folder-path"
file_path = r"C:\path\to\your\file.xlsx" # Replace with actual file path
file_name = file_path.split("\\")[-1]
@robes7
robes7 / Pdf_to_word.py
Created February 15, 2025 12:21
PDF to WORD Converter
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:
@robes7
robes7 / Html_to_excel.py
Last active February 15, 2025 12:20
HTML to Excel converter
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
@robes7
robes7 / Tab_refresher.py
Created February 15, 2025 12:06
Refresh EDGE tab
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")
@robes7
robes7 / Select_export_send.py
Created February 15, 2025 12:05
Select from DB, export file and send it via mail
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
@robes7
robes7 / Monitor_services_in_mail.ps1
Last active February 17, 2025 10:59
Monitor services of server via mail
# 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'
@robes7
robes7 / Monitor_servers_in_mail.ps1
Last active February 15, 2025 11:35
Ping servers and notify via mail
# 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"
@robes7
robes7 / Unzip_encrypted.py
Created February 15, 2025 11:30
Unzip encrypted files
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)