Age | Commit message (Collapse) | Author |
|
The file splitting requires mktemp and csplit
|
|
We can literally use mv -v instead! Why didn't I think to look at the
manpage for mv! Lol
|
|
Rather than looking at the environment varible otherwise use the local
automv.d directory - set it to something more centralized in the
environement e.g /usr/local/etc/automv.d/
Also the logs were unclear what was happening so extracted the find
query into a function to be able to run/rerun it a few times to improve
the existing logging. I wonder if there is a better way to print what is
happening in the xargs w/o repeating the move a bunch:
fn_mv {
echo "Moving: $1 to $2"
mv $1 $2
}
and call:
find ... | xargs -I'{}' fn_mv {} $target
Perhaps?
|
|
Automv script will allow a cronjob to easily move files from one dir to
another based on a find regex query. You can dynamically set what files
to look for and where using .conf files in the automv.d folder present
next to the script - or by setting its location in AUTOMV_DIR.
Dev note: I specifically avoided using $HOME/.local/automv.d/ because my
specific use case the user whose cron this will be in doesn't have a
home directory. An improvement could be expanding the smart defaults to
doing something like:
if [[ -n "$HOME" ]]; then
if [[ -d $HOME/.local/automv.d ]]; then
# use that
else # etc
else # etc
But I don't like long bash if/else nesting so I figured just set a local
default otherwise override in the env
|