Scripting Archives - Thoughts https://blog.jstassen.com/tag/scripting/ A place for collecting my miscellaneous thoughts. Tue, 07 Dec 2021 06:55:37 +0000 en-US hourly 1 https://wordpress.org/?v=7.0.7 92836340 Batch conversion of SVG to PDF (updated) https://blog.jstassen.com/2021/04/batch-conversion-of-svg-to-pdf-updated/ https://blog.jstassen.com/2021/04/batch-conversion-of-svg-to-pdf-updated/#respond Sat, 17 Apr 2021 05:55:00 +0000 https://blog.jstassen.com/?p=1281 Thanks to Runbgmn for the original instructions on batch conversion of svg to pdf. The instructions there are currently out of date, so here are an updated set of steps I found to batch converting svg to pdf with Inkscape. Batch conversion of svg to pdf is very helpful. This is how it can be … Continue reading Batch conversion of SVG to PDF (updated) →

The post Batch conversion of SVG to PDF (updated) appeared first on Thoughts.

]]>
Thanks to Runbgmn for the original instructions on batch conversion of svg to pdf. The instructions there are currently out of date, so here are an updated set of steps I found to batch converting svg to pdf with Inkscape.

Batch conversion of svg to pdf is very helpful. This is how it can be done under Mac OSX for free, no need to buy any software nor upload anything.

The Setup for Batch Conversion of SVG to PDF

  1. Get the free vector graphics program Inkscape and install it
  2. We’ll want to make inkscape available as a command in our terminal path. To do so, In a terminal execute create a link:
sudo ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape /usr/local/bin/inkscape

3. Create a new file svg2pdf.sh with the following contents:

#!/bin/bash

# get path from command line
MYWD=$1

for file in *.svg
do
  echo $file $MYWD
  cat "$file" | inkscape --pipe --export-filename="${file%%.*}.pdf"
done

5. Make it executable:

chmod +x svg2pdf.sh

Usage

Run the script with the path to the folder filled with *.svg files to be batch converted to *.pdf.

Example:

bash svg2pdf.sh ~/Documents/folderOfSVGsToConvert

This will convert all svg files in the given directory into pdf.

Next you can use Adobe Acrobat, Preview, ghost script or many other programs to combine them into one single pdf file instead of multiple pdf files.

Combining Multiple PDFs into a Single PDF

Combining with Preview

The simplest way to combine multiple PDF files into a single one on Mac OSX is to using Preview.

A screenshot showing Preview application and how to open them thumbnails pane in the menu by opening View → Thumbnails or pressing Option + Command + 2. Which is handy for combining PDFs after batch conversion of svg to pdf files.
  1. Open the first page with Preview.
  2. Open thumbnails pane in the menu View → Thumbnails
  3. Drag and drop each PDF file into the thumbnail pane in the page order you’d like.

Combining with pdfunite

Install poppler, a PDF manipulation toolset.

brew install poppler

You’ll now have pdfunite command available, run it on your directory of PDFs to create a single PDF.

pdfunite *.pdf book.pdf

Speaking of Books

Looking for good engineering books? Take a look at my top rated engineering books I’ve found and recommend!

The post Batch conversion of SVG to PDF (updated) appeared first on Thoughts.

]]>
https://blog.jstassen.com/2021/04/batch-conversion-of-svg-to-pdf-updated/feed/ 0 1281
Script: Delayed Sleep / Hibernate https://blog.jstassen.com/2014/01/script-delayed-sleep-hibernate/ https://blog.jstassen.com/2014/01/script-delayed-sleep-hibernate/#respond Sat, 04 Jan 2014 11:00:11 +0000 http://blog.jstassen.com/?p=358 I often sleep or hibernate my computer when I’m finished for the night so I can resume where I left off in the morning. Problem: I was listening to some music I figured I’d like to fall asleep to. However, I don’t allow my pc to fall asleep on its own. So how could I … Continue reading Script: Delayed Sleep / Hibernate →

The post Script: Delayed Sleep / Hibernate appeared first on Thoughts.

]]>
I often sleep or hibernate my computer when I’m finished for the night so I can resume where I left off in the morning.

Problem: I was listening to some music I figured I’d like to fall asleep to. However, I don’t allow my pc to fall asleep on its own. So how could I (for just this one time) set a delayed Hibernate?

With a batch command naturally!

timeout /t 1200 /nobreak && rundll32.exe powrprof.dll,SetSuspendState 0,1,0

There you have it. Timeout + Hibernate/Sleep. A silly solution for a silly problem.

The post Script: Delayed Sleep / Hibernate appeared first on Thoughts.

]]>
https://blog.jstassen.com/2014/01/script-delayed-sleep-hibernate/feed/ 0 358
Script: Unhide Network Drive Folders https://blog.jstassen.com/2013/03/script-unhide-network-drive-folders/ https://blog.jstassen.com/2013/03/script-unhide-network-drive-folders/#comments Wed, 20 Mar 2013 00:51:28 +0000 http://blog.jstassen.com/?p=182 There is an infection going around that hides all folders on a network drive and sets them as system folders. Here is a script I wrote that will remove the hidden and system attributes all folders/files in a directory you specify. It uses the “attrib -h -s” and is not recursive into subdirectories. For complete … Continue reading Script: Unhide Network Drive Folders →

The post Script: Unhide Network Drive Folders appeared first on Thoughts.

]]>
There is an infection going around that hides all folders on a network drive and sets them as system folders. Here is a script I wrote that will remove the hidden and system attributes all folders/files in a directory you specify.
It uses the “attrib -h -s” and is not recursive into subdirectories.

For complete removal of the infection, naturally scan all machines. Remove any rouge autorun.ini files and rouge .exe files on the network drive.

Download: UnhideNetworkDriveFolders.v1.zip

I haven’t tested on all system setups and naturally comes with no warranty.

Update 3/22/2013

This script can only be run against a folder ( C:/Production/Shared ) not against an actual mapped drive ( S:/ ) at this time.

Update 3/27/2013

Here is a quick list of things to check regarding cleaning up the infection/worm.

  • Scan all PCs with Malwarebytes
    • Cleanup the the startup items
    • Cleanup and rouge exe files located
      • C:\User\%Username%
      • C:\User\%Username%\AppData
      • C:\User\%Username%\AppData\Roaming
    • Find proccess the infection is running under. Example:  jjhhgg.exe
  • Network drives, Flashdrives, External Harddrives
    • Delete all *.exe that mimic a folder and have a folders name
    • Delete autorun.inf
    • Delete x.mpg
    • Deltee anything else odd, rouge .exe files, photos files with .exe extentions
    • CMD Prompt, browse to the folder and run
      • attrib -h -s
      • Note this only unhides files, not folders.
    • CMD Prompt, browse to the folder and run
      • FOR /F "tokens=*" %i IN ('DIR /A:D /b') do attrib -h -s "%i"
      • Note this only unhides folders, make sure to have the quotation marks

 

The post Script: Unhide Network Drive Folders appeared first on Thoughts.

]]>
https://blog.jstassen.com/2013/03/script-unhide-network-drive-folders/feed/ 2 182
Script: PowerShell Calendar Rights https://blog.jstassen.com/2013/03/script-powershell-calendar-rights/ https://blog.jstassen.com/2013/03/script-powershell-calendar-rights/#respond Sat, 16 Mar 2013 00:47:52 +0000 http://blog.jstassen.com/?p=170 Here is a great snip-it of PowerShell script for granting a user rights to view (or even modify) all user calendars in an organization. Excellent for managers. Get-Mailbox | ForEach {Add-MailboxFolderPermission $_":\Calendar" -User email@address.com -AccessRights Reviewer}

The post Script: PowerShell Calendar Rights appeared first on Thoughts.

]]>
Here is a great snip-it of PowerShell script for granting a user rights to view (or even modify) all user calendars in an organization. Excellent for managers.

Get-Mailbox | ForEach {Add-MailboxFolderPermission $_":\Calendar"
-User email@address.com -AccessRights Reviewer}

The post Script: PowerShell Calendar Rights appeared first on Thoughts.

]]>
https://blog.jstassen.com/2013/03/script-powershell-calendar-rights/feed/ 0 170
Grouping Mailboxes with PowerShell https://blog.jstassen.com/2013/01/grouping-mailboxes-with-powershell/ https://blog.jstassen.com/2013/01/grouping-mailboxes-with-powershell/#respond Mon, 14 Jan 2013 04:12:32 +0000 http://blog.jstassen.com/?p=15 Here is a snip-it of PowerShell Code I am using to group and count the number of mailboxes on an Microsoft Exchange Server 2008 using CustomAttribute1. On our server we have a unique ID stored in the CustomAttribute1 for mailboxes that belong to different groupings. For example in the CustomAttribute1 we store the company ID, … Continue reading Grouping Mailboxes with PowerShell →

The post Grouping Mailboxes with PowerShell appeared first on Thoughts.

]]>
Here is a snip-it of PowerShell Code I am using to group and count the number of mailboxes on an Microsoft Exchange Server 2008 using CustomAttribute1.

On our server we have a unique ID stored in the CustomAttribute1 for mailboxes that belong to different groupings. For example in the CustomAttribute1 we store the company ID, in CustomAttribute2 we may store the service level they pay for. We found the need to keep a count of the number of mailboxes belonging to different companies.

$CountMembers = @{}
Get-Mailbox | foreach-object {$CountMembers[$_.CustomAttribute1]++}
$CountMembers

Naturally from here we can append the | Out-File Report.txt to save to a txt file. Ideally I would like to export to a csv, however this data format doesn’t support that. I may look further into this in the future.

We can use this method to group mailboxes by any common attribute actually. Say the count the number of mailboxes on each database using $_.Database

The post Grouping Mailboxes with PowerShell appeared first on Thoughts.

]]>
https://blog.jstassen.com/2013/01/grouping-mailboxes-with-powershell/feed/ 0 15