Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mftsf.sh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
mftsf.sh
Commits
fbce42bf
Commit
fbce42bf
authored
Sep 07, 2017
by
Richard Torenvliet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
0 deletions
+112
-0
mftsf.sh
mftsf.sh
+112
-0
No files found.
mftsf.sh
0 → 100755
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment