Skip to content

Instantly share code, notes, and snippets.

@Forest-Dewberry
Created June 14, 2022 19:58
Show Gist options
  • Save Forest-Dewberry/ab317bf6b683f0b85df99c8b52285fbe to your computer and use it in GitHub Desktop.
Save Forest-Dewberry/ab317bf6b683f0b85df99c8b52285fbe to your computer and use it in GitHub Desktop.
#!/usr/bin/env bashSCRIPT_IS_RUN_FROM=$(pwd)
PS_DEFAULT_DIR="$1"
PS_DEFAULT_DIR="$(wslpath -- "$PS_DEFAULT_DIR")"
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; # get the script dir
# Now loop through every file in MyFunctionsModules
# Each file should have a directory of the same name created in and be copied to that directory.
cd -- "$SCRIPT_DIR"
cd -- "$2"
FILESFROM=$(pwd)
for i in *
do
if test "$i"
then
filename=$(basename -- "$i")
extension="${filename##*.}"
filewoext="${filename%.*}"
cd -- "$SCRIPT_IS_RUN_FROM" # The PS_DEFAULT_DIR can be input relative to where the script was run from or an absolute path.
mkdir -- "$PS_DEFAULT_DIR/$filewoext" 2>/dev/null
cd -- "$FILESFROM"
cp -- "$filename" "$PS_DEFAULT_DIR/$filewoext/$filewoext.psm1"
cd "$FILESFROM"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment