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.
|
# 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 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))
|
[[ "${targets}" = "" ]] && targets=($(ls))
|
||||||
|
|
||||||
local today="$(date +%Y)"
|
mkdir ${selected_year} 2> /dev/null
|
||||||
mkdir ${today} 2> /dev/null
|
|
||||||
|
|
||||||
process() {
|
process() {
|
||||||
local year=$(stat --format=%y ${target})
|
local year=$(stat --format=%y ${target})
|
||||||
year=${year%%-*}
|
year=${year%%-*}
|
||||||
|
|
||||||
if [[ "${year}" = "${today}" ]]; then
|
if [[ "${year}" = "${selected_year}" ]]; then
|
||||||
rcp -- ${target} ./${today}/
|
rcp -- ${target} ./${selected_year}/
|
||||||
else
|
else
|
||||||
_iterate_skip
|
_iterate_skip
|
||||||
fi
|
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.
|
`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.
|
## Docker.
|
||||||
|
|
||||||
Command|Description
|
Command|Description
|
||||||
|
@ -152,6 +146,12 @@ Command|Description
|
||||||
`dcpu [SERVICES]`|Docker compose pull & up specified services.
|
`dcpu [SERVICES]`|Docker compose pull & up specified services.
|
||||||
`dcul [SERVICES]`|Docker compose up & attach to logs for 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.
|
## Ffmpeg.
|
||||||
|
|
||||||
Command|Description
|
Command|Description
|
||||||
|
@ -221,7 +221,7 @@ Command|Description
|
||||||
---|---
|
---|---
|
||||||
`group_ext [FILES]`|Group files by extension.
|
`group_ext [FILES]`|Group files by extension.
|
||||||
`group_year [FILES]`|Group files and dirs by year.
|
`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.
|
## Help.
|
||||||
|
|
||||||
|
|
Reference in a new issue