Add some pre-existing scripts.

This commit is contained in:
Lukáš Kucharczyk
2020-07-30 15:44:20 +02:00
parent 848694ed11
commit e1434f1a1e
9 changed files with 181 additions and 0 deletions

39
sort_files_into_folders Executable file
View File

@ -0,0 +1,39 @@
#!/bin/env bash
filecount=$(ls -l | wc -l)
echo "File count: ${filecount}"
splitby=100
directory_count=$(($filecount/$splitby+1))
echo "Directories to split into: ${directory_count}"
echo "--START--"
count=0
current_dir=1
test -d $current_dir || mkdir $current_dir
overall=0
for file in *
do
# if [ $overall -eq 20 ]
# then
# break
# fi
overall=$((overall+1))
if [ -d "$file" ]
then
# echo "Not a file, skipping."
continue
fi
echo "Current file: ${file}"
count=$((count+1))
if [ $count -gt $splitby ]
then
current_dir=$((current_dir+1))
count=1
echo "Current count: ${count} (threshold overflow)"
mkdir "$current_dir"
else
echo "Current count: ${count}"
fi
echo "Moving to: ${current_dir}"
mv "$file" "$current_dir"
echo "--"
done