-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlagacy.sh
executable file
·61 lines (52 loc) · 1.86 KB
/
lagacy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# get the present dir and parent dir
currnDir=$(pwd)
echo "CurrnDir: $currnDir"
parentDirName=$(dirname "$currnDir")
echo "ParentDirName: $parentDirName"
# Set the source and destination directories
src_dir="${currnDir}"
# echo "src_dir : $src_dir"
mkdir -p "${parentDirName}/sorted-cvs"
dst_dir="${parentDirName}/sorted-cvs"
# echo "dst_dir : $dst_dir"
# Create the destination directories if they don't exist
mkdir -p "${dst_dir}/civil_eng"
mkdir -p "${dst_dir}/mechanical_eng"
mkdir -p "${dst_dir}/software_eng"
# Loop through the files in the source directory
for file in "${src_dir}"/*
do
# Get the file extension
ext="${file##*.}"
# Check if the file is a PDF
if [ "${ext,,}" = "pdf" ]
then
# Get the file name without the extension
name="${file%.*}"
filename=$(basename "$file")
echo "Filename: $filename"
dirname=$(dirname "$file")
echo "Dirname: $dirname"
# Check the contents of the PDF for keywords
if pdftotext "${file}" - | grep -i "civil engineering"
then
# Move the file to the civil engineering directory
echo "this is name: ${name}"
echo "this is ext: ${ext}"
echo "this is file: ${file}"
mv "${file}" "./Civil_Engin/${filename}.pdf"
# elif pdftotext "${file}" - | grep -qi "mechanical engineering"
# then
# # Move the file to the mechanical engineering directory
# mv "${file}" "${dst_dir}/mechanical_eng/${name}.pdf"
# elif pdftotext "${file}" - | grep -qi "software engineering"
# then
# # Move the file to the software engineering directory
# mv "${file}" "${dst_dir}/software_eng/${name}.pdf"
# else
# # Move the file to a default directory
# mv "${file}" "${dst_dir}/misc/${name}.pdf"
fi
fi
done