Skip to content

Commit cb606a1

Browse files
committed
Initial commit
1 parent d3513dd commit cb606a1

8 files changed

+530
-0
lines changed

.gitignore

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Go template
3+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
4+
*.o
5+
*.a
6+
*.so
7+
8+
# Folders
9+
_obj
10+
_test
11+
12+
# Architecture specific extensions/prefixes
13+
*.[568vq]
14+
[568vq].out
15+
16+
*.cgo1.go
17+
*.cgo2.c
18+
_cgo_defun.c
19+
_cgo_gotypes.go
20+
_cgo_export.*
21+
22+
_testmain.go
23+
24+
*.exe
25+
*.test
26+
*.prof
27+
### Linux template
28+
*~
29+
30+
# temporary files which can be created if a process still has a handle open of a deleted file
31+
.fuse_hidden*
32+
33+
# KDE directory preferences
34+
.directory
35+
36+
# Linux trash folder which might appear on any partition or disk
37+
.Trash-*
38+
### OSX template
39+
*.DS_Store
40+
.AppleDouble
41+
.LSOverride
42+
43+
# Icon must end with two \r
44+
Icon
45+
46+
# Thumbnails
47+
._*
48+
49+
# Files that might appear in the root of a volume
50+
.DocumentRevisions-V100
51+
.fseventsd
52+
.Spotlight-V100
53+
.TemporaryItems
54+
.Trashes
55+
.VolumeIcon.icns
56+
.com.apple.timemachine.donotpresent
57+
58+
# Directories potentially created on remote AFP share
59+
.AppleDB
60+
.AppleDesktop
61+
Network Trash Folder
62+
Temporary Items
63+
.apdisk
64+
### Windows template
65+
# Windows image file caches
66+
Thumbs.db
67+
ehthumbs.db
68+
69+
# Folder config file
70+
Desktop.ini
71+
72+
# Recycle Bin used on file shares
73+
$RECYCLE.BIN/
74+
75+
# Windows Installer files
76+
*.cab
77+
*.msi
78+
*.msm
79+
*.msp
80+
81+
# Windows shortcuts
82+
*.lnk
83+
84+
.gitignore
85+
.idea/
86+
*.iml
87+
playground/
88+
*.db

README.md

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# ![gitql](https://rawgit.com/DiSiqueira/Gorganizer/master/gorganizer-logo.png)
2+
3+
# Gorganizer ![Language Badge](https://img.shields.io/badge/Language-Go-blue.svg) ![Dependencies Badge](https://img.shields.io/badge/Dependencies-BoltDB-brightgreen.svg) ![License Badge](https://img.shields.io/badge/License-MIT-blue.svg) ![Status Badge](https://img.shields.io/badge/Status-Beta-brightgreen.svg)
4+
5+
====
6+
7+
Gorganizer is a Go program inspired by [Bhrigu Srivastava][bhrigu123] [Classifier Project][classifier].
8+
9+
The Gorganizer goal is to be a perfect tool providing a stupidly easy to use and fast program to organize your files based on its extension.
10+
11+
[bhrigu123]: https://github.com/bhrigu123
12+
[classifier]: https://github.com/bhrigu123/classifier
13+
14+
## Project Status
15+
16+
Gorganizer is on beta
17+
18+
Bolt is stable, more features will be added and full unit tests will be made.
19+
Pull Requests [are welcome](https://github.com/DiSiqueira/Gorganizer#social-coding)
20+
21+
![](https://i.imgur.com/2rFfn9i.gif)
22+
23+
## Features
24+
25+
- It's perfect to organize your downloads folder
26+
- Instantly organize your files
27+
- Customize to your needs
28+
- Easy to add rules
29+
- Easy to delete default rules
30+
- Stupidly [easy to use](https://github.com/DiSiqueira/Gorganizer#usage)
31+
- Very fast start up and response time
32+
- Uses natives libs
33+
- Only one dependency - [BoltDB](https://github.com/boltdb/bolt)
34+
- Option to organize your files
35+
36+
## Installation
37+
38+
### Option 1: Download binary
39+
40+
```bash
41+
$
42+
```
43+
44+
### Option 2: From source
45+
46+
```bash
47+
$ go get github.com/boltdb/bolt/...
48+
$ git clone https://github.com/DiSiqueira/Gorganizer.git
49+
$ cd Gorganizer/src
50+
$ go build *.go
51+
```
52+
53+
## Usage
54+
55+
### Basic usage
56+
57+
```bash
58+
# Organize your current directory
59+
$ ./gorganizer
60+
```
61+
62+
### Add new rule
63+
64+
```bash
65+
# Add .py to Python folder
66+
$ ./gorganizer -newrule=py:Python
67+
```
68+
69+
### Delete existing rule
70+
71+
```bash
72+
# Delete txt rule
73+
$ ./gorganizer -delrule=txt
74+
```
75+
76+
### Print all rules
77+
78+
```bash
79+
# Delete txt rule
80+
$ ./gorganizer -allrules=true
81+
```
82+
83+
### Move organized files to another folder
84+
85+
```bash
86+
# Run in current directory and move organized files to ~/Downloads
87+
$ ./gorganizer -output=~/Downloads
88+
```
89+
90+
### Run in other directory
91+
92+
```bash
93+
# Run in ~/Downloads
94+
$ ./gorganizer -directory=~/Downloads
95+
```
96+
97+
### Run in other directory and send organized files to a organized one
98+
99+
```bash
100+
# Run in ~/Downloads
101+
$ ./gorganizer -directory=~/Downloads -output=~/Documents
102+
```
103+
104+
### Show help
105+
106+
```bash
107+
$ ./gorganizer -h
108+
```
109+
110+
## Program Help
111+
112+
![](http://image.prntscr.com/image/27c361f3891c461d83584577eb18ec72.png)
113+
114+
## Contributing
115+
116+
### Bug Reports & Feature Requests
117+
118+
Please use the [issue tracker](https://github.com/DiSiqueira/Gorganizer/issues) to report any bugs or file feature requests.
119+
120+
### Developing
121+
122+
PRs are welcome. To begin developing, do this:
123+
124+
```bash
125+
$ go get github.com/boltdb/bolt/...
126+
$ git clone --recursive [email protected]:DiSiqueira/Gorganizer.git
127+
$ cd Gorganizer/src/
128+
$ go run *.go
129+
```
130+
131+
## Social Coding
132+
133+
1. Create an issue to discuss about your idea
134+
2. [Fork it] (https://github.com/DiSiqueira/Gorganizer/fork)
135+
3. Create your feature branch (`git checkout -b my-new-feature`)
136+
4. Commit your changes (`git commit -am 'Add some feature'`)
137+
5. Push to the branch (`git push origin my-new-feature`)
138+
6. Create a new Pull Request
139+
7. Profit! :white_check_mark:
140+
141+
## License
142+
143+
The MIT License (MIT)
144+
145+
Copyright (c) 2013-2015 Diego Siqueira
146+
147+
Permission is hereby granted, free of charge, to any person obtaining a copy
148+
of this software and associated documentation files (the "Software"), to deal
149+
in the Software without restriction, including without limitation the rights
150+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
151+
copies of the Software, and to permit persons to whom the Software is
152+
furnished to do so, subject to the following conditions:
153+
154+
The above copyright notice and this permission notice shall be included in
155+
all copies or substantial portions of the Software.
156+
157+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
159+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
160+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
161+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
162+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
163+
THE SOFTWARE.

bin/gorganizer

2.51 MB
Binary file not shown.

gorganizer-logo.png

32.3 KB
Loading

src/bolt.go

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package main
2+
3+
import (
4+
"github.com/boltdb/bolt"
5+
"bytes"
6+
"fmt"
7+
"strings"
8+
)
9+
10+
func boltGet(key string) string {
11+
12+
var result []byte
13+
14+
db.View(func(tx *bolt.Tx) error {
15+
b := tx.Bucket([]byte(bucketName))
16+
v := b.Get([]byte(key))
17+
result = v
18+
return nil
19+
})
20+
21+
return string(result)
22+
}
23+
24+
func boltSet(key, value string) error {
25+
err = db.Update(func(tx *bolt.Tx) error {
26+
b := tx.Bucket([]byte(bucketName))
27+
err := b.Put([]byte(key), []byte(value))
28+
return err
29+
})
30+
31+
return err
32+
}
33+
34+
func boltDelete(key string) error {
35+
err = db.Update(func(tx *bolt.Tx) error {
36+
b := tx.Bucket([]byte(bucketName))
37+
err := b.Delete([]byte(key))
38+
return err
39+
})
40+
41+
return err
42+
}
43+
44+
func boltScanExt() {
45+
db.View(func(tx *bolt.Tx) error {
46+
// Assume bucket exists and has keys
47+
c := tx.Bucket([]byte(bucketName)).Cursor()
48+
49+
prefix := []byte("ext:")
50+
fmt.Println("Extension | Folder")
51+
for k, v := c.Seek(prefix); bytes.HasPrefix(k, prefix); k, v = c.Next() {
52+
53+
ext := strings.Split(string(k),":")
54+
55+
fmt.Printf("%s | %s\n", ext[1], v)
56+
}
57+
58+
return nil
59+
})
60+
}

0 commit comments

Comments
 (0)