IvanDovgalyuk / fog

πŸ—‚οΈ File Organizer written in Go. Can do flatten out folders, rename based on patterns/regex, etc...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ—‚οΈ fog

Files Organizer in Go

A little tool to help organize files easier.

Installation

Install Go

Get Go from https://go.dev/doc/install

Or via package manager: chocolatey:

choco install go

Please making sure your go version is up to date.

# Current latest version 1.77.7
go version 

Install/Update this tool

Install via go command:

go install github.com/kwchang0831/fog@latest

Note

This is an old prototype project of mine a couple of years back. It is still usable surprisely.
However, Not well tested. So, Not recommended to use in any production environment.
Please use it at your own risk.

Every committing changes will generate a log for you to revert back.

Usages

folderout

Move files in the folder in current directory out of their folders.

fog folderout "." -w

"." : Target directory. Defaults to "." if omitted.

-w : Commit changes. Without the flag wil be dry run.

BeforeAfter
.
β”œβ”€β”€ SomeVideo_S01E01
    β”œβ”€β”€ SomeVideo_S01E01.mp4
    β”œβ”€β”€ SomeVideo_S01E01.jpg 
β”œβ”€β”€ SomeVideo_S01E02
    β”œβ”€β”€ SomeVideo_S01E02.avi
            
.
β”œβ”€β”€ SomeVideo_S01E01.mp4
β”œβ”€β”€ SomeVideo_S01E01.jpg 
β”œβ”€β”€ SomeVideo_S01E02.avi
            

folderin

Move SomeVideo_SXXEXX into their individual folder.

fog folderin "." -w

"." : Target directory. Defaults to "." if omitted.

-w : Commit changes. Without the flag wil be dry run.

BeforeAfter
.
β”œβ”€β”€ SomeVideo_S01E01.mp4
β”œβ”€β”€ SomeVideo_S01E01.jpg
β”œβ”€β”€ SomeVideo_S01E02.avi
            
.
β”œβ”€β”€ SomeVideo_S01E01
    β”œβ”€β”€ SomeVideo_S01E01.mp4
    β”œβ”€β”€ SomeVideo_S01E01.jpg
β”œβ”€β”€ SomeVideo_S01E02
    β”œβ”€β”€ SomeVideo_S01E02.avi
            

revert

Undo committed actions from target log file.

fo revert -w [pathToTheLog]

-w : Commit changes. Without the flag wil be dry run.

replacename

Remove [Bad] in file name only

fog replacename "\[Bad\]" "" -d "." -w

-d: Set directory.

-w : Commit changes. Without the flag wil be dry run.

BeforeAfter
.
β”œβ”€β”€ [Bad]SomeVideo_Folder[Bad] 
β”œβ”€β”€ [Bad]SomeVideo_S01E01[Bad].mp4
β”œβ”€β”€ [Bad]SomeVideo_S01E02[Bad].avi
            
.
β”œβ”€β”€ [Bad]SomeVideo_Folder[Bad]  
β”œβ”€β”€ SomeVideo_S01E01.mp4
β”œβ”€β”€ SomeVideo_S01E02.avi
            

Replace [Bad] in folder name only

fog replacename "\[Bad\]" "" -d "." -m1 -w

-d: Set directory.

-w : Commit changes. Without the flag wil be dry run.

-m1: Mode 1: Folder name only.

BeforeAfter
.
β”œβ”€β”€ [Bad]SomeVideo_Folder[Bad]   
β”œβ”€β”€ [Bad]SomeVideo_S01E01[Bad].mp4
β”œβ”€β”€ [Bad]SomeVideo_S01E02[Bad].avi
            
.
β”œβ”€β”€ SomeVideo_Folder
β”œβ”€β”€ [Bad]SomeVideo_S01E01[Bad].mp4
β”œβ”€β”€ [Bad]SomeVideo_S01E02[Bad].avi
            

Remove [Bad] in both folder name and file name

fog replacename "\[Bad\]" "" -d "." -m2 -w

-d: Set directory.

-w : Commit changes. Without the flag wil be dry run.

-m2: Mode 2: Folder and File name.

BeforeAfter
.
β”œβ”€β”€ [Bad]SomeVideo_Folder[Bad]   
β”œβ”€β”€ [Bad]SomeVideo_S01E01[Bad].mp4
β”œβ”€β”€ [Bad]SomeVideo_S01E02[Bad].avi
            
.
β”œβ”€β”€ SomeVideo_Folder
β”œβ”€β”€ SomeVideo_S01E01.mp4
β”œβ”€β”€ SomeVideo_S01E02.avi
            

Replace filename with regex

fog replacename "(.*)(SomeVideo)(.*)(S[0-9]+E[0-9]+)(.*)(\.(mp4|avi))" "$2-$4$6" -d "." -w

-d: Set directory.

-w : Commit changes. Without the flag wil be dry run.

Learn more and try regex, see regex101.

BeforeAfter
.
β”œβ”€β”€ [20240202]SomeVideo_S01E01[Bad].mp4
β”œβ”€β”€ [20240207]SomeVideo_S01E02[Bad].avi
            
.
β”œβ”€β”€ SomeVideo-S01E01.mp4
β”œβ”€β”€ SomeVideo-S01E02.avi
            

Show Help

For more information, please check help command.

fog

Output

File Organizer in Go provides commands to help you batch edit filenames and organize files.

Usage:
  fog [command]

Available Commands:
  completion        Generate the autocompletion script for the specified shell
  folderin          move files into their own folders.
  folderout         Move files out of folders
  help              Help about any command
  move              Move matching files/folders into target directory.
  renameafterfolder Rename files inside matching folders with the folder name.
  replacename       Replace name using the search pattern and replace pattern.
  revert            revert commands issued.
  rmemptydir        remove empty folders.

Flags:
  -h, --help   help for fog

Use "fog [command] --help" for more information about a command.

Development

Get dependencies

go mod tidy

Build

go build

About

πŸ—‚οΈ File Organizer written in Go. Can do flatten out folders, rename based on patterns/regex, etc...

License:MIT License


Languages

Language:Go 100.0%