52

I download a lot of different stuff all the time. Often times I don't actually get around to cleaning it up. Thus, I decided I needed to build a script to further encourage my bad habits.

Here I've built a script for both Windows and Linux. It's designed to take all the files in the current directory and move them into their own folders based on their extensions. Why is this useful?

It's fucking useful when you're not having to swim through fucking mountains of content.

Anyways without any further ado here are the scripts.

Linux

#!/bin/bash
for i in *.*; do
filename=$(basename -- "$i")
extension="${filename##*.}"
extension="$extension"files
mkdir "$extension"
mv "$i" "$extension"
done

Windows

@echo off
for %%i in (*.*) do (
if not exist %%~xifile md %%~xifile
)
for %%i in (*.*) do (
if "%%i" NEQ "movingFiles.bat" move "%%i" "%%~xifile"
)

Comments
Add Comment