Created
September 22, 2017 20:20
-
-
Save sadiefp/3cd1b6d4e53f39a41aabc52217182f36 to your computer and use it in GitHub Desktop.
Bash script to move files with no extension into a folder.
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