Skip to content

Instantly share code, notes, and snippets.

@sadiefp
Created September 22, 2017 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadiefp/3cd1b6d4e53f39a41aabc52217182f36 to your computer and use it in GitHub Desktop.
Save sadiefp/3cd1b6d4e53f39a41aabc52217182f36 to your computer and use it in GitHub Desktop.
Bash script to move files with no extension into a folder.
#!/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