Created
July 6, 2018 23:04
-
-
Save thiamsantos/eeae0e4bbcc95adfb25363bb92d9f937 to your computer and use it in GitHub Desktop.
flat folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ORIGIN="${1}" | |
DEST="${2}" | |
function move_files { | |
ORIGIN="${1}" | |
if test -f "${ORIGIN}" | |
then | |
echo "${ORIGIN} is a file" | |
FILE_NAME=$(basename "${ORIGIN}") | |
mv "${ORIGIN}" "${DEST}/${FILE_NAME}" | |
elif test -d "${ORIGIN}" | |
then | |
echo "${ORIGIN} is a directory" | |
for FILE in "${ORIGIN}"/* | |
do | |
move_files "${FILE}" | |
done | |
else | |
echo "${ORIGIN} is not valid" | |
fi | |
} | |
move_files "${ORIGIN}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment