Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mftsf.sh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Torenvliet
mftsf.sh
Commits
fbce42bf
Commit
fbce42bf
authored
7 years ago
by
Richard Torenvliet
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mftsf.sh
+112
-0
112 additions, 0 deletions
mftsf.sh
with
112 additions
and
0 deletions
mftsf.sh
0 → 100755
+
112
−
0
View file @
fbce42bf
#!/bin/bash
N
=
500
#Set Script Name variable
SCRIPT
=
`
basename
${
BASH_SOURCE
[0]
}
`
function
HELP
{
echo
-e
\\
n
"Help documentation for
${
SCRIPT
}
."
\\
n
echo
-e
"Basic usage:
$SCRIPT
gradebook.zip"
\\
n
echo
"Command line switches are optional. The following switches are
recognized."
echo
"-d --Set output directory.
${
BOLD
}
$OUTPUT_DIR
${
NORM
}
."
echo
-e
"-h --Displays this help message. No further functions
are performed."
\\
n
echo
-e
"Example:
${
BOLD
}
$SCRIPT
-d assignment1
gradebook.zip
${
NORM
}
"
\\
n
exit
1
}
NUMARGS
=
$#
if
[
$NUMARGS
-lt
0
]
;
then
HELP
exit
1
fi
findDir
=
""
outputDir
=
""
skip
=
0
while
getopts
:i:o:n:s:h FLAG
;
do
case
$FLAG
in
s
)
skip
=
$OPTARG
;;
i
)
findDir
=
$OPTARG
;;
o
)
outputDir
=
$OPTARG
;;
n
)
N
=
$OPTARG
;;
h
)
#show help
HELP
;;
\?
)
echo
-e
\\
n
"Option
-
${
BOLD
}
$OPTARG
${
NORM
}
not allowed."
HELP
;;
esac
done
if
[
-z
$findDir
]
;
then
HELP
;
exit
1
;
fi
if
[
-z
$outputDir
]
;
then
HELP
;
exit
1
;
fi
echo
finddir
$findDir
echo
outputDir
$outputDir
# shift ops, all optional args are now removed $1 will have to be the filename
shift
$((
OPTIND-1
))
#
echo
"Creating folder '
$outputDir
' .. "
mkdir
-p
$outputDir
#
echo
"Searching files in '
$findDir
'"
fileList
=(
`
find
"
$findDir
"
-maxdepth
1
-type
f
`
)
||
echo
''
if
[
${#
fileList
[*]
}
-eq
0
]
;
then
echo
"No files in '
$findDir
' detected, exiting..."
;
exit
1
;
fi
fileList
=
`
find
"
$findDir
"
-maxdepth
1
-type
f
`
IFS
=
$'
\n
'
counter
=
0
currentOutputPath
=
"
$outputDir
/part_
$counter
"
echo
"Creating first folder '
$currentOutputPath
' ..."
mkdir
-p
"
$currentOutputPath
"
echo
"Skipping
$skip
files ..."
for
f
in
$fileList
;
do
let
counter
=
counter+1
;
if
[
$counter
-lt
$skip
]
;
then
echo
"Skipping
$counter
$f
"
continue
fi
echo
"cp
$f
$currentOutputPath
/
`
basename
"
$f
"
`
"
cp
$f
$currentOutputPath
/
`
basename
"
$f
"
`
if
[
`
expr
$counter
%
$N
`
-eq
0
]
;
then
currentOutputPath
=
"
$outputDir
""/part_
$counter
"
mkdir
-p
"
$currentOutputPath
"
echo
"Counter
$counter
"
fi
done
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment