Skip to content

Instantly share code, notes, and snippets.

View alst74's full-sized avatar

Alexander Ståhlberg alst74

  • Sandviken/Sweden
View GitHub Profile
$sleep = 2 #Sleeptime in seconds between checks
$maxtry = 10 #Nr of tr
$successfile = "c:\temp\success.txt"
$failedfile = "c:\temp\fail.txt"
Write-Host "Waiting for deploy to complete"
for ($i=1; $i -le $maxtry; $i++) {
if (Test-Path "${successfile}") {
Write-Host "${successfile} found - Deploy was SUCCESSFUL!!"
Break
}
@alst74
alst74 / move-files.ps1
Created November 7, 2019 09:43
Move files recursivly with Powershell
$SRC = "c:\temp"
$FILES = "*.mp4", "*.jpg"
$DST = "c:\destfolder"
for ($i=0; $i -lt $FILES.length; $i++) {
Get-ChildItem -Recurse -Path "$SRC\$FILES[$i]" | Move-Item -Destination $DST -WhatIf
# Write-Host("File: ") $FILES[$i]
}
@alst74
alst74 / testfile.sh
Created December 18, 2020 13:41
Bash loops and tests
#!/bin/bash
FILENAME=$1
for FILENAME in "$@"; do
if ! [ -e "$FILENAME" ]; then
echo "File not found ($FILENAME). Skipping..."
elif [ -d "$FILENAME" ]; then
ORIG_IFS=$IFS
IFS=$(echo -en "\n\b")
for F in $(find "$FILENAME" -type f); do
ls -lah $F
@alst74
alst74 / .bash_profile
Created January 12, 2022 10:51
bash_profile
HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
HISTCONTROL="ignoredups:ignorespace"
HISTIGNORE="ls *:history"
HISTSIZE=1000