Code Monkey home page Code Monkey logo

tsmv's Introduction

tsmv

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
  -n, --name              name based slice (format %Y[._/-]?%m[._/-]?%d[._/-]?%H?)
      --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 testfile-20160722-01.log
-rw-r--r--  1 tkuchiki  tkuchiki  0  8 22 00:00 testfile-20160722.log
-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

$ find ./tmp/src/ -type f | xargs ./tsmv -c -t ./tmp/dest/ -f "%Y%m%d" -n --dry-run
mkdir ./tmp/dest/20160722
mv ./tmp/src//testfile-20160722-01.log ./tmp/dest/20160722/testfile-20160722-01.log
mv ./tmp/src//testfile-20160722.log ./tmp/dest/20160722/testfile-20160722.log

$ find ./tmp/src/ -type f | xargs ./tsmv -c -t ./tmp/dest/ -f "%Y%m%d%H" -n --dry-run
mkdir ./tmp/dest/2016072201
mv ./tmp/src//testfile-20160722-01.log ./tmp/dest/2016072201/testfile-20160722-01.log
mkdir ./tmp/dest/2016072200
mv ./tmp/src//testfile-20160722.log ./tmp/dest/2016072200/testfile-20160722.log

run

$ find ./tmp/src/ -type f | xargs ./tsmv -c -t ./tmp/dest/ -f "%Y%m%d%H" -n

$ ls tmp/dest/
2016072200      2016072201

$ ls tmp/dest/20160722*
tmp/dest/2016072200:
testfile-20160722.log

tmp/dest/2016072201:
testfile-20160722-01.log

$ 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

tsmv's People

Contributors

tkuchiki avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.