Skip to content

Instantly share code, notes, and snippets.

@sadiefp
Last active September 22, 2017 20:21
Show Gist options
  • Save sadiefp/0a199a583ebc09190a6124255fad6cfc to your computer and use it in GitHub Desktop.
Save sadiefp/0a199a583ebc09190a6124255fad6cfc to your computer and use it in GitHub Desktop.
Bash script to move files with no extension into folders
#!/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