-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter
More file actions
executable file
·108 lines (79 loc) · 2.02 KB
/
Counter
File metadata and controls
executable file
·108 lines (79 loc) · 2.02 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/csh
#a script for nabbing every n'th data dump.
#Others are moved into the subdirectory, defined in $Garbage
#Tunable variables: nKeep, nstart, nSteps (defaults to number of hierarchy files)
# CountAll, KeepFirstAndLast
set nstart = 0
set n = $nstart
#set nSteps = `ls *.hierarchy |wc -l`
set nSteps = 470
#how many to take (of the ones THAT EXIST,so if only data0000, data0003 and data0006 exist, and nKeep = 3, we keep data0006)
#We also keep the first and the last.
#if CountAll = 0, keep every nKeep'th file of Existing.
#if CountAll = 1, keep every nKeep'th file of Sequentially Numbered.
# so if nKeep=3, and there's data0000, data0003, data0006
# CountAll = 1 takes all 3, CountAll = 0 takes only data0006
set CountAll = 0
set KeepFirstAndLast = 1
set nKeep = 1
#what directory to store the files we will delete
set Garbage = Garbage
#make it
if( !( -e $Garbage ) ) mkdir $Garbage
#initial filename: $basename$k$j$i$h
set basename = "data"
set h=0
set i=0
set j=0
set k=0
set counter = 0
set keep = 0
while( $n <= $nSteps )
set keep = 0
set step = $k$j$i$h
set Files = "$basename"$step
#either count numbers or existing files.
if( $CountAll == 1 ) then
@ counter = $counter + 1
else
if( -e $Files ) @ counter = $counter + 1
endif
#determine if we should keep this set or move it.
if( $counter % $nKeep == 0 ) then
set keep = 1
endif
if( $KeepFirstAndLast == 1 ) then
if( $n == $nstart ) set keep = 1
if( $n == $nSteps ) set keep = 1
endif
#move it if we're not keeping it.
if( $keep == 0 ) then
echo Not keeping $Files
mv $Files* Garbage
else
echo Keeping $Files
mv $Files* ../Drive512Save
endif
#
# this is the incrementer. You don't really need to look past this.
#
@ n = $n + 1
@ h = $h + 1
if( $h >= 10 ) then
set h = 0
@ i = $i + 1
if( $i >= 10 ) then
set i = 0
@ j = $j + 1
if( $j >= 10 ) then
set j = 0
@ k = $k + 1
if( $k >= 10 ) then
echo "too many files"
exit
endif
endif
endif
endif
end
#moo