new tools for folder manipulation

This commit is contained in:
ville rantanen
2015-04-27 13:06:08 +03:00
parent c0a49222db
commit e63ada72cf
5 changed files with 165 additions and 69 deletions

28
FolderFlat Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
function help() {
echo "Flatten the directory structure from the current folder downwards"
echo "Files in subfolders will be renamed / -> _"
echo "Empty folders are removed"
echo " -f to force action "
}
function helpexit() {
help
exit
}
[[ -z "$1" ]] && {
help
echo "Are you sure? Break with ctrl-c"
read i
}
[[ "$1" = "-h" ]] && helpexit
IFS=$'\n'
for f in $( find . -mindepth 2 -type f -path '*.*' -printf %P'\n' );
do mv -iv "$f" "$( echo $f | sed s,[/],_,g )"
done
find . -depth -type d -empty -delete