folder archiver
This commit is contained in:
1
bin/archive_subfolders
Symbolic link
1
bin/archive_subfolders
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../files/archive_subfolders
|
||||||
49
files/archive_subfolders
Executable file
49
files/archive_subfolders
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
function helpexit() {
|
||||||
|
echo Archive the subfolders of the current directory
|
||||||
|
echo " -z Compress. If not passed, will ask after tar archive"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ "$1" = "-h" ]] && helpexit
|
||||||
|
|
||||||
|
echo Archive the following folders:
|
||||||
|
|
||||||
|
find . -mindepth 1 -maxdepth 1 -type d | sort | tr \\n " "
|
||||||
|
echo ''
|
||||||
|
echo '<ctrl-c> to quit'
|
||||||
|
read foo
|
||||||
|
|
||||||
|
|
||||||
|
find . -mindepth 1 -maxdepth 1 -type d -print0 | sort | while read -r -d "" d; do
|
||||||
|
echo -n $d
|
||||||
|
tar cvf "$d.tar" $d > "$d.tar.txt" &
|
||||||
|
PID=$!
|
||||||
|
while kill -0 "$PID" >/dev/null 2>&1; do
|
||||||
|
sleep 5
|
||||||
|
echo -en "\r"
|
||||||
|
ls -sh "$d.tar" | xargs echo -n
|
||||||
|
done
|
||||||
|
echo -en "\r"
|
||||||
|
ls -sh "$d.tar"
|
||||||
|
done
|
||||||
|
[[ "$1" = "-z" ]] || {
|
||||||
|
echo 'Proceed to compress? <ctrl-c> to quit'
|
||||||
|
read foo
|
||||||
|
}
|
||||||
|
|
||||||
|
find . -mindepth 1 -maxdepth 1 -type d -print0 | sort | while read -r -d "" d; do
|
||||||
|
ls -sh "$d.tar"
|
||||||
|
gzip "$d.tar"
|
||||||
|
PID=$!
|
||||||
|
while kill -0 "$PID" >/dev/null 2>&1; do
|
||||||
|
sleep 5
|
||||||
|
echo -en "\r"
|
||||||
|
ls -sh "$d.tar" | xargs echo -n
|
||||||
|
done
|
||||||
|
echo -en "\r"
|
||||||
|
ls -sh "$d.tar"
|
||||||
|
done
|
||||||
|
|
||||||
Reference in New Issue
Block a user