GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - shootercheng/disk: File scanning and large file cleanup command-line tool(文件扫描、清除大文件 命令行工具)

BranchesTags
Open more actions menu

Latest commit

 

History

34 Commits
34 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
internal
internal
 
 
pkg
pkg
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
FAQ.md
FAQ.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README_zh.md
README_zh.md
 
 
go.mod
go.mod
 
 
main.go
main.go
 
 

Repository files navigation

File Scan and File Cleanup Command Line Tool

中文

How to run the program, provides 3 ways:

  1. Run using source code
  2. Install using go install
  3. Download executable file directly

Run Using Source Code

  1. Download the source code
  2. Prepare test files for experience, test file structure as follows:
E:\CODE\GO\TOOLSET\ROOT
│  root_1.txt
│  root_2.txt
│
├─dir1
│  │  1.txt
│  │
│  └─dir1-1
│          1-1.txt
│
├─dir2
│      2.txt
│
└─dir3
        3.txt
  1. Run the scan program, generate scan.txt file in the project root directory
go run main.go -r=E:\CODE\GO\TOOLSET\ROOT -t=5

Command line parameter parsing, -t=5 files exceeding 5 bytes will be recorded in scan.txt, which will be read during the cleanup task in the next step

Please enter the prompted command line parameters, parameters without default value (default) are required
  -m string
        Execution method: scan or clean (default "scan")
  -o string
        Scan output file (default "scan.txt")
  -r string
        Scan root path
  -t int
        File size threshold (default 1073741824)

Check the generated scan file content as follows:

[File]:E:\CODE\GO\TOOLSET\ROOT\dir1\1.txt,7
[File]:E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1\1-1.txt,11
[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1,11
[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir1,18
[File]:E:\CODE\GO\TOOLSET\ROOT\dir3\3.txt,8
[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir3,8
[File]:E:\CODE\GO\TOOLSET\ROOT\root_1.txt,13
[File]:E:\CODE\GO\TOOLSET\ROOT\root_2.txt,11
[Folder]:E:\CODE\GO\TOOLSET\ROOT,51
  1. Run file cleanup, interactively clean files in the command line
E:\code\go\toolset\disk>go run main.go -m=clean
Starting file cleanup task, scan result file path: scan.txt
Confirm delete file: E:\CODE\GO\TOOLSET\ROOT\dir1\1.txt? Y or N: y
Delete file: E:\CODE\GO\TOOLSET\ROOT\dir1\1.txt, successful
Confirm delete file: E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1\1-1.txt? Y or N: y
Delete file: E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1\1-1.txt, successful
Confirm delete file: E:\CODE\GO\TOOLSET\ROOT\dir3\3.txt? Y or N: y
Delete file: E:\CODE\GO\TOOLSET\ROOT\dir3\3.txt, successful
Confirm delete file: E:\CODE\GO\TOOLSET\ROOT\root_1.txt? Y or N: y
Delete file: E:\CODE\GO\TOOLSET\ROOT\root_1.txt, successful
Confirm delete file: E:\CODE\GO\TOOLSET\ROOT\root_2.txt? Y or N: y
Delete file: E:\CODE\GO\TOOLSET\ROOT\root_2.txt, successful
Confirm delete folder: E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1? Y or N: y
Delete folder: E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1, successful
Confirm delete folder: E:\CODE\GO\TOOLSET\ROOT\dir1? Y or N: y
Delete folder: E:\CODE\GO\TOOLSET\ROOT\dir1, successful
Confirm delete folder: E:\CODE\GO\TOOLSET\ROOT\dir3? Y or N: y
Delete folder: E:\CODE\GO\TOOLSET\ROOT\dir3, successful
Confirm delete folder: E:\CODE\GO\TOOLSET\ROOT? Y or N: n

Check the cleanup results, view scan.txt content as follows, successfully deleted files will be marked as {deleted}

{deleted}[File]:E:\CODE\GO\TOOLSET\ROOT\dir1\1.txt,7
{deleted}[File]:E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1\1-1.txt,11
{deleted}[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir1\dir1-1,11
{deleted}[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir1,18
{deleted}[File]:E:\CODE\GO\TOOLSET\ROOT\dir3\3.txt,8
{deleted}[Folder]:E:\CODE\GO\TOOLSET\ROOT\dir3,8
{deleted}[File]:E:\CODE\GO\TOOLSET\ROOT\root_1.txt,13
{deleted}[File]:E:\CODE\GO\TOOLSET\ROOT\root_2.txt,11
[Folder]:E:\CODE\GO\TOOLSET\ROOT,51

Install Using go install

go install github.com/shootercheng/disk@latest
  1. Check if installation is successful, execute disk command
E:\code\go\toolset\disk>disk
Please enter the prompted command line parameters, parameters without default value (default) are required
  -m string
        Execution method: scan or clean (default "scan")
  -o string
        Scan output file (default "scan.txt")
  -r string
        Scan root path
  -t int
        File size threshold (default 1073741824)
  1. Run the scan program, -t specifies file threshold size in bytes
disk -r=E:\CODE\GO\TOOLSET\ROOT -t=5
  1. Run file cleanup
disk -m=clean

Download Released Executable File to Run

  1. Windows amd64 https://github.com/shootercheng/disk/releases/download/v2.0.0/disk.exe
  2. Linux amd64 https://github.com/shootercheng/disk/releases/download/v2.0.0/disk
$ wget https://github.com/shootercheng/disk/releases/download/v2.0.0/disk
$ chmod +x ./disk
$ ./disk -h

Run Tests

go test ./tests/...

About

File scanning and large file cleanup command-line tool(文件扫描、清除大文件 命令行工具)

Topics

disk-cleaningdisk-scanning

Resources

Readme
Apache-2.0 license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.