Results 1 to 1 of 1
#!/bin/bash
clear
echo "################################################# ###############"
echo "Hello," $USER
echo "Bash version is" $BASH_VERSION
echo "Current directory is" $PWD
echo "Changing directory..."
cd /home/admin/Test
echo "Working directory changed to:" $PWD
echo ...
- 12-23-2011 #1Just Joined!
- Join Date
- Dec 2011
- Posts
- 0
Bash script to move all files into a directory named for them
#!/bin/bash
clear
echo "################################################# ###############"
echo "Hello," $USER
echo "Bash version is" $BASH_VERSION
echo "Current directory is" $PWD
echo "Changing directory..."
cd /home/admin/Test
echo "Working directory changed to:" $PWD
echo "################################################# ###############"
# save and change IFS
OLDIFS=$IFS
IFS=$'\n'
for FILE in *
do
DIR="$FILE"
echo "Processing" $FILE
mkdir ${DIR%.*}
echo "Creating Directory For" ${FILE%.*}
mv $FILE ${DIR%.*}
echo "Moving $FILE into Directory"
echo "Processing next file..."
done
Hope this *helps someone*
Enjoy


Reply With Quote
