Moving files to subfolders

It’s not uncommon for me to have to tidy up directories full of files by moving them to their own subfolders, named for each file. It’s become common enough that I wrote a little Powershell function to do it repeatedly.

After saving the below script as a .psm1 file you’ll be able to open PS and import the file. I tend to save it to “C:\Scripts\MoveToSubfolders.psm1” – then I can open PS and run “Import-Module C:\Scripts\MoveToSubfolders.psm1”.

Once it’s been imported I can then use the function on whatever folder of files I need to tidy by simply running “MoveToSubfolders” and following the function with the folder I need to sort. It works well for making movies tidier.1`

function MoveToSubfolders([string]$Folder = ".\" ){
# Convert relative folder paths to full paths
$FullPath = Resolve-Path $Folder

# Generate list of all files in the specified directory.
$Files = Get-ChildItem -Path ((Get-Item -Path $FullPath -Verbose).FullName)

# For each object in the directory, do the following:
$Files | ForEach-Object {
    # Generate the variables 
    $FileName = $_.FullName
    $FileFolderName = $_.BaseName
    $DestinationFolder = "$FullPath\$FileFolderName"
    $MoveDestination = "$DestinationFolder\$($_.Name)"

    # Check if the destination directory exists
    if(!(Test-Path $DestinationFolder))
    {
        # Create the directory using FileName (minus file extension) if it does not exist
        New-Item -Path $DestinationFolder -ItemType Directory
    }
    # Move the file to the new directory
    Move-Item -ErrorAction SilentlyContinue $FileName $MoveDestination
}
}
# Actually allow this module to have functions used outside via import
Export-ModuleMember -Function *
Export-ModuleMember -Variable *


Permanent link to this article: https://www.berserkir.net/wordpress/moving-files-to-subfolders/

Media Portal

Not long ago I posted about configuring ‘Monitorr‘.
As an internal tool, it was surprisingly useful. However, I quickly decided it could be much more useful as a landing page for people who I’ve given access to my media.

It handles linking and monitoring of multiple services – some only I have access to, some others do.

To make all the services work nicely, I also set up a reverse proxy system using the BaseURL settings in the various systems I use (Radarr, Sonarr, Lidarr etc), and proxy rules in IIS. See more on that here.
Thanks to the proxy setup, no more ‘unresponsive’ messages – since it only has to check that it’s listening, authentication is separate. Yay!

Permanent link to this article: https://www.berserkir.net/wordpress/media-portal/

Reverse Proxy (with IIS)

I run a lot of different pieces of software on my server. Sonarr, Radarr, Lidarr… just to name a few.
All of these different systems listen on different ports, and I got tired of having so many ports forwarded and so many different ports to remember.

Enter: Reverse Proxy.

Continue reading

Permanent link to this article: https://www.berserkir.net/wordpress/reverse-proxy-with-iis/

Monitorr

I recently set up a little web app called Monitorr on my server. It sits in my webserver directories, and gives me a quick glance at what services are online and offline (of the ones I’ve told it to monitor).

It’s an Open-Source project, that I came across on Github. Setup was ridiculously easy.

You can find it here.

Continue reading

Permanent link to this article: https://www.berserkir.net/wordpress/monitorr/

Speedster Build (Part 1)

So I made a start and stripped down my donor machine the other night (no photos – just a stock rolling chassis).

Now – transplanting bits to the new chassis plate, and putting things together.

Motor is mounted, and diffs/driveline.
Top plate needs some modification to fit the new motor (Dremel to the rescue!).
I need some other bearings to do the Traxxas spur mod, so that’s going to be delayed – gives me a next stage of updates, so that’s cool.

Next up is steering assembly, then on to the electronics (cutting, soldering, fitting etc – I want this to be clean inside).  Pictures below.

Permanent link to this article: https://www.berserkir.net/wordpress/speedster-build-part-1/