Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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