-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathput.sh
More file actions
executable file
·52 lines (50 loc) · 1.49 KB
/
put.sh
File metadata and controls
executable file
·52 lines (50 loc) · 1.49 KB
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
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob
# clear Windows artifacts
rm -f ./*.exe 2>/dev/null || true
rm -f cmake-build-debug/*.exe 2>/dev/null || true
EXCLUDE=(Template.cpp Checker.cpp)
is_excluded(){ local f="$1"; for e in "${EXCLUDE[@]}"; do [[ "$f" == "$e" ]] && return 0; done; return 1; }
process(){
local file="$1" base name
base="${file##*/}"; name="${base%.cpp}"
if [[ "$name" =~ ^(Bronze|Silver|Gold|Platinum) ]]; then
mkdir -p USACO; mv -f -- "$file" USACO/; echo "[USACO] Moved $file → USACO"; return
fi
if [[ "$name" =~ ^[0-9]{3,4}[A-Za-z] ]]; then
mkdir -p Codeforces; mv -f -- "$file" Codeforces/; echo "[CF] Moved $file → Codeforces"; return
fi
if [[ "$name" == *-* ]]; then
mkdir -p CSES; mv -f -- "$file" CSES/; echo "[CSES] Moved $file → CSES"
fi
}
if [[ $# -eq 0 ]]; then
for f in ./*.cpp; do
b="${f##*/}"
if is_excluded "$b"; then echo "[skip] $b"; else process "$f"; fi
done
exit 0
fi
prefix="$1"
start=$(( (prefix/50)*50 ))
end=$(( start+49 ))
rangeFolder="${start}-${end}"
contestDir="Codeforces/${rangeFolder}/${prefix}"
mkdir -p -- "$contestDir"
if [[ $# -ge 2 ]]; then
letters="$2"
files=()
for (( i=0; i<${#letters}; i++ )); do
c="${letters:i:1}"
files+=( ${prefix}${c}*.cpp )
done
else
files=( ${prefix}*.cpp )
fi
if (( ${#files[@]} == 0 )); then
echo "[err] No files matching \"${prefix}*.cpp\""
else
mv -f -- "${files[@]}" "$contestDir"/
echo "[success] Moved ${#files[@]} file(s) to \"$contestDir\""
fi