summaryrefslogtreecommitdiff
path: root/movetextfiles.sh
blob: 132fe14fb8606a87112065da1f312a41fe04260a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

if [[ -z $1 ]]; then
    echo "in what folder do you want to search for text files to move into a subfolder?"
    exit 0
fi

dst='./textfiles/'
if [[ ${2} ]]; then
    dst=${2}
fi

#check that mime type is text. if so, move to 'text' folder
for f in `find ${1} -maxdepth 1 -type f`; do
    if [[ `file -i ${f} | grep 'text/'` ]]; then
        mv ${f} ${dst}
    fi 
done