bash : add archive_rename to rename archives.
This commit is contained in:
parent
904edf910d
commit
644b335458
|
@ -146,6 +146,31 @@ unarchive()
|
|||
done
|
||||
}
|
||||
|
||||
# rename archive.
|
||||
# usage: archive_rename [ARCHIVE] [NAME]
|
||||
archive_rename()
|
||||
{
|
||||
# get params.
|
||||
local target="${1}"
|
||||
local name="${2}"
|
||||
|
||||
# check params.
|
||||
if [[ "${target}" = "" || "${name}" = "" ]]; then
|
||||
echo "usage: archive_rename [ARCHIVE] [NAME]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# remove old name.
|
||||
local data="${target##*_}"
|
||||
local new_name="${name}_${data}"
|
||||
|
||||
# prepare status.
|
||||
local status="${target} -> ${new_name}"
|
||||
|
||||
# rename.
|
||||
mv -- "${target}" "${new_name}" && echo "${status}" || echo -e "${color_red}${status}: error.${color_default}"
|
||||
}
|
||||
|
||||
# export everything, primarily for use with parallel..
|
||||
export -f archive archive_fast archive_check unarchive
|
||||
|
||||
|
|
Reference in a new issue