Skip to content

Instantly share code, notes, and snippets.

@thiamsantos
Created July 6, 2018 23:04
Show Gist options
  • Save thiamsantos/eeae0e4bbcc95adfb25363bb92d9f937 to your computer and use it in GitHub Desktop.
Save thiamsantos/eeae0e4bbcc95adfb25363bb92d9f937 to your computer and use it in GitHub Desktop.
flat folder
#!/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