Created
May 30, 2017 17:23
-
-
Save dtxe/fefcc6c3bfd06ef9bd640ae4d98e4ede to your computer and use it in GitHub Desktop.
Symlink CTF *.ds, with renaming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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