diff --git a/README.md b/README.md index e325e4d..18f010f 100644 --- a/README.md +++ b/README.md @@ -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: + --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: + [] 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 +``` diff --git a/setup_example.sh b/setup_example.sh new file mode 100755 index 0000000..9f911dd --- /dev/null +++ b/setup_example.sh @@ -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 +