Group : Group by specified year.
This commit is contained in:
parent
35cd601e45
commit
b9c47d7df0
|
@ -38,20 +38,28 @@ function group_year() {
|
|||
}
|
||||
|
||||
# Copy files from current year to the named dir.
|
||||
function group_year_current() {
|
||||
# Usage: group_year_copy <YEAR> [FILES]
|
||||
function group_year_copy() {
|
||||
local IFS=$'\n'
|
||||
local targets=(${@})
|
||||
local selected_year="${1}"
|
||||
local targets=(${@:2})
|
||||
|
||||
if [[ "${selected_year}" = "" ]]; then
|
||||
help group_year_copy
|
||||
return 2
|
||||
fi
|
||||
|
||||
# All files by default.
|
||||
[[ "${targets}" = "" ]] && targets=($(ls))
|
||||
|
||||
local today="$(date +%Y)"
|
||||
mkdir ${today} 2> /dev/null
|
||||
mkdir ${selected_year} 2> /dev/null
|
||||
|
||||
process() {
|
||||
local year=$(stat --format=%y ${target})
|
||||
year=${year%%-*}
|
||||
|
||||
if [[ "${year}" = "${today}" ]]; then
|
||||
rcp -- ${target} ./${today}/
|
||||
if [[ "${year}" = "${selected_year}" ]]; then
|
||||
rcp -- ${target} ./${selected_year}/
|
||||
else
|
||||
_iterate_skip
|
||||
fi
|
||||
|
|
14
.doc/Bash.md
14
.doc/Bash.md
|
@ -126,12 +126,6 @@ Command|Description
|
|||
---|---
|
||||
`da [BOX]`|Create/Attach to the box. Uses name `main` by default.
|
||||
|
||||
## Doc.
|
||||
|
||||
Command|Description
|
||||
---|---
|
||||
`doc_bash`|Generate a markdown file with all the help info. Outputs to `~/.doc/Bash.md`.
|
||||
|
||||
## Docker.
|
||||
|
||||
Command|Description
|
||||
|
@ -152,6 +146,12 @@ Command|Description
|
|||
`dcpu [SERVICES]`|Docker compose pull & up specified services.
|
||||
`dcul [SERVICES]`|Docker compose up & attach to logs for specified services.
|
||||
|
||||
## Doc.
|
||||
|
||||
Command|Description
|
||||
---|---
|
||||
`doc_bash`|Generate a markdown file with all the help info. Outputs to `~/.doc/Bash.md`.
|
||||
|
||||
## Ffmpeg.
|
||||
|
||||
Command|Description
|
||||
|
@ -221,7 +221,7 @@ Command|Description
|
|||
---|---
|
||||
`group_ext [FILES]`|Group files by extension.
|
||||
`group_year [FILES]`|Group files and dirs by year.
|
||||
`group_year_current`| Copy files from current year to the named dir.
|
||||
`group_year_copy <YEAR> [FILES]`|Copy files from current year to the named dir.
|
||||
|
||||
## Help.
|
||||
|
||||
|
|
Reference in a new issue