Last active
September 22, 2017 20:21
-
-
Save sadiefp/0a199a583ebc09190a6124255fad6cfc to your computer and use it in GitHub Desktop.
Bash script to move files with no extension into folders
This file contains 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 | |
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | |
FILES=${parent_path}/files/* | |
counter=0 | |
for f in $FILES | |
do | |
if [ -f "$f" ]; then | |
file=${f##*/} | |
if [[ ${file} != *"."* ]]; then | |
if [[ "$counter" -lt 2499 ]]; then | |
mv $f ${parent_path}/files/no-extension/batch_01/$file | |
echo "$file" >> ${parent_path}/files/no-extension/no_extension_1.txt | |
else | |
mv $f ${parent_path}/files/no-extension/batch_02/$file | |
echo "$file" >> ${parent_path}/files/no-extension/no_extension_2.txt | |
fi | |
echo "$file moved" | |
counter=$((counter+1)) | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment