Skip to content

Instantly share code, notes, and snippets.

@dtxe
Created May 30, 2017 17:23
Show Gist options
  • Save dtxe/fefcc6c3bfd06ef9bd640ae4d98e4ede to your computer and use it in GitHub Desktop.
Save dtxe/fefcc6c3bfd06ef9bd640ae4d98e4ede to your computer and use it in GitHub Desktop.
Symlink CTF *.ds, with renaming
#!/bin/bash
#
# Simeon Wong
if [ -d $1 ]
then
# make destination directory
mkdir $2
SRCBASE=$(basename $1 .ds)
DSTBASE=$(basename $2 .ds)
for SRCFILE in $(ls -1 $1)
do
DSTFILE="${SRCFILE//$SRCBASE/$DSTBASE}"
# link subfolder items into destimation directory
ln -s $1/$SRCFILE $2/$DSTFILE
done
else
echo "Error: $1 not found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment