FSweeper - An intuitive and simple file management automation tool.

FSweeper

Build PkgGoDev Go Report Card

An intuitive and simple file management automation tool.
Read this guide and write rules for organizing file storage in just a couple of minutes.

Installation

Pick a binary from the releases.

Build from source

Download and install Go https://golang.org/doc/install.

Get the package:

go get github.com/reugn/fsweeper

Read this guide on how to compile and install the application.

Usage

Command line options list:

./fsweeper --help

Usage of ./fsweeper:
  -actions
        Show supported actions
  -conf string
        Configuration file path (default "conf.yaml")
  -configure
        Open default configuration file in $EDITOR
  -filters
        Show supported filters
  -version
        Show version

Configuration

fsweeper uses YAML as a configuration file format.
A default configuration file name could be set using the FSWEEPER_CONFIG_FILE environment variable. It will fallback to conf.yaml otherwise.
Use --conf=custom.yaml parameter to run against a custom configuration file.

Let's start with a simple example:

rules:
    - path: ./examples/files
      recursive: true
      op: OR
      actions:
        - action: echo
          payload: "Found size"
      filters:
        - filter: size
          payload: gt 10000
        - filter: size
          payload: eq 0

This configuration will look for files that are bigger than 10000 bytes or empty and print out "Found size" message on each.

What if we want to move all JSON files to an archive folder:

rules:
    - path: ./examples/files
      recursive: true
      actions:
        - action: move
          payload: ./examples/archive
        - action: echo
          payload: "Found JSON file"
      filters:
        - filter: ext
          payload: .json

Variables and pipelines

We can build dynamic configurations using variables and pipelines. Variables introduce a set of dynamic placeholders to be substituted in runtime. Pipelines chain together a series of template commands to compactly express a series of transformations.

Let's see an example:

vars:
    dateTimeFormat: "2006.01.02[15-04-05]"
rules:
    - path: ./examples/files
      recursive: true
      op: AND
      actions:
        - action: echo
          payload: "Found {{ .FileName | upper | quote }} at {{ .DateTime }}, size {{ .FileSize }}"
      filters:
        - filter: name
          payload: "[0-9]+"
        - filter: contains
          payload: "1234"
Variables Description
.FileSize Returns the context file size
.FileName Returns the context file name
.FilePath Returns the context file full path
.FileExt Returns the context file extension
.Time Current Time (default format: "15-04-05")1
.Date Current Date (default format: "2006-01-02")1
.DateTime Current DateTime (default format: "2006-01-02[15-04-05]")1
.Ts Current Unix epoch time

1You can override timeFormat, dateFormat, and dateTimeFormat in the configuration file.

Pipeline functions Description
trim Removes leading and trailing white spaces
upper Returns a string with all Unicode letters mapped to their upper case
lower Returns a string with all Unicode letters mapped to their lower case
quote Wraps a string with double quotes
head n Takes the first "n" characters of the input string
len Returns a string representation of the input length

License

MIT

Similar Resources

QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enables you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to a CSV file

QueryCSV enable you to load CSV files and manipulate them using SQL queries then after you finish you can export the new values to CSV file

Dec 22, 2021

Dragonfly is an intelligent P2P based image and file distribution system.

Dragonfly is an intelligent P2P based image and file distribution system.

Dragonfly Note: The master branch may be in an unstable or even broken state during development. Please use releases instead of the master branch in o

Jan 9, 2023

A basic file server automatically generates self certificates and serves the given folder.

A basic file server automatically generates self certificates and serves the given folder.

Jul 20, 2022

File uploader with support for multiple hosts and progress reporting written in Go.

File uploader with support for multiple hosts and progress reporting written in Go.

go-upload File uploader with support for multiple hosts and progress reporting written in Go. Windows, Linux, macOS and Android binaries Usage Upload

Dec 18, 2022

Provide an upload endpoint that stores files on pinata and returns a json response with the uploaded file pinata url

Purpose Build a template repository to get to coding as quickly as possible, by starting from a common template which follows the guidelines here Feat

Dec 30, 2021

Extract profiles and tasks information from CSV file

Footsite-Bot ideas from jw6602 Extract profiles and tasks information from CSV f

Nov 25, 2022

A very light-weight file sharing platform, including server and client

file-transporter A very light-weight file sharing platform, including server and client Installation git clone https://github.com/vence722/file-transp

Jan 12, 2022

Upgit - Upgit helps you simply upload any file to your Github repository and then get a raw URL for it

Upgit - Upgit helps you simply upload any file to your Github repository and then get a raw URL for it

Upgit - Upgit helps you simply upload any file to your Github repository and then get a raw URL for it

Dec 27, 2022

🌳 Go Bonzai™ File Completer, normal completion looking at files and directories with trailing slashes on directories (like bash)

🌳 Go Bonzai™ File Completer, normal completion looking at files and directories with trailing slashes on directories (like bash)

Apr 12, 2022
Comments
  • os.Rename can't move files across drive letters and samba shares

    os.Rename can't move files across drive letters and samba shares

    https://github.com/reugn/fsweeper/blob/78f59e91210524441ec55ab76e80f65e3faeb7ae/rules/actions.go#L31

    I've worked on a very similar task on a personal project and I've been browsing your code to get inspiration\places where I could improve my knowledge.

    Care that os.Rename can't move files across different drives\shares on Windows. A full os.Copy and subsequent os.Remove is needed.

A tool for moving files into directories by file extensions
A tool for moving files into directories by file extensions

The tool for moving files into directories by file extensions Example before moving structure: moving into same extension dir result: moving into diff

Dec 6, 2021
A command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format
A command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format

Logbook CLI This is a command line tool for mainly exporting logbook records from Google Spreadsheet to PDF file in EASA format. It also supports rend

Feb 6, 2022
searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

Nov 9, 2021
A database/file backup tool with web interfaces
A database/file backup tool with web interfaces

backup-x 带Web界面的数据库/文件备份增强工具。原理:执行自定义shell命令输出文件,增强备份功能。

Dec 26, 2022
A useful file search tool
A useful file search tool

go-find 花了半天时间写的一个的文件名、文件内容搜索工具,主要是为了hvv中快速发现敏感文件、配置文件等。

Sep 22, 2022
Ghostinthepdf - This is a small tool that helps to embed a PostScript file into a PDF

This is a small tool that helps to embed a PostScript file into a PDF in a way that GhostScript will run the PostScript code during the

Dec 20, 2022
A small tool for sending a single file to another machine

file-traveler A small tool for sending a single file to another machine. Build g

Dec 28, 2021
Simple go script that converts csv file into a json document

csv-go-parser Simple go script that converts csv file into a json document. CSV Input: id,first_name,last_name,email,avatar,ip_address 1,Pauline,Hirth

Jun 4, 2022
Dontfile-simple - The simplest version of an online file manager

dontfile-simple The simplest version of an online file manager. Built With Golan

Jan 12, 2022
Bigfile -- a file transfer system that supports http, rpc and ftp protocol https://bigfile.site
Bigfile -- a file transfer system that supports http, rpc and ftp protocol   https://bigfile.site

Bigfile ———— a file transfer system that supports http, rpc and ftp protocol 简体中文 ∙ English Bigfile is a file transfer system, supports http, ftp and

Dec 31, 2022