Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuchiki committed Aug 22, 2016
1 parent 208c72f commit dec507d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
89 changes: 88 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,89 @@
# tsmv
time sliced mv
tsmv is time sliced mv.

## Installation

Download from https://github.com/tkuchiki/tsmv/releases


## Usage

```
$ ./tsmv --help
usage: tsmv [<flags>] [<filepaths>...]
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
-t, --target-directory=DIRECTORY
move all source arguments into directory
-f, --format="%Y%m%d" strftime format
-c, --create-directory create target directory
-r, --recursive create directories recursively
-m, --mode=0755 file mode
--dry-run enable dry-run mode
--version Show application version.
Args:
[<filepaths>] some file paths
```

## Examples

```
$ ./setup_example.sh
$ ls tmp/
dest src
$ ls -l tmp/src/
total 0
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 22 00:00 testfile1
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 22 00:00 testfile2
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 21 00:00 testfile3
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 20 00:00 testfile4
```

### dry-run

```
$ find ./tmp/src/ -type f | ./tsmv -c -t ./tmp/dest/ --dry-run
mkdir ./tmp/dest/20160822
mv ./tmp/src//testfile1 ./tmp/dest/20160822/testfile1
mv ./tmp/src//testfile2 ./tmp/dest/20160822/testfile2
mkdir ./tmp/dest/20160821
mv ./tmp/src//testfile3 ./tmp/dest/20160821/testfile3
mkdir ./tmp/dest/20160820
mv ./tmp/src//testfile4 ./tmp/dest/20160820/testfile4
$ find ./tmp/src/ -type f | xargs ./tsmv -c -t ./tmp/dest/ -f "%Y-%m-%d" --dry-run
mkdir ./tmp/dest/2016-08-22
mv ./tmp/src//testfile1 ./tmp/dest/2016-08-22/testfile1
mv ./tmp/src//testfile2 ./tmp/dest/2016-08-22/testfile2
mkdir ./tmp/dest/2016-08-21
mv ./tmp/src//testfile3 ./tmp/dest/2016-08-21/testfile3
mkdir ./tmp/dest/2016-08-20
mv ./tmp/src//testfile4 ./tmp/dest/2016-08-20/testfile4
```

### run

```
$ find ./tmp/src/ -type f | ./tsmv -c -t ./tmp/dest/
$ ls ./tmp/dest/
20160820 20160821 20160822
$ ls -l ./tmp/dest/20160820/
total 0
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 20 00:00 testfile4
$ ls -l ./tmp/dest/20160821
total 0
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 21 00:00 testfile3
$ ls -l ./tmp/dest/20160822
total 0
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 22 00:00 testfile1
-rw-r--r-- 1 tkuchiki tkuchiki 0 8 22 00:00 testfile2
```
10 changes: 10 additions & 0 deletions setup_example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

mkdir -p tmp/src
mkdir -p tmp/dest

touch -t 201608220000 tmp/src/testfile1
touch -t 201608220000 tmp/src/testfile2
touch -t 201608210000 tmp/src/testfile3
touch -t 201608200000 tmp/src/testfile4

0 comments on commit dec507d

Please sign in to comment.