View Single Post
Old 29-Nov-2007, 03:06 AM   #2 (permalink)
Anilrgowda
Administrator
 
Anilrgowda's Avatar

Posts: 18,715
Join Date: Jan 2006
Rep Power: 10 Anilrgowda is on a distinguished road

IM:
Default Re: Linux script needed for file moving and directory creating

Sorry, I though you had the first part already. Here it is in bash.

#!/bin/bash

# set these to the appropriate directories
HOLD=~/HOLD
CUSTOMERS=~/CUSTOMERS

for FILE in $HOLD/*; do
# get the customer number
CUSTNUM=`echo $FILE | awk -F\- {'print $2'}`

# check if the customer dir exists, if not create it
if [ ! -d $CUSTOMERS/$CUSTNUM ];then
mkdir $CUSTOMERS/$CUSTNUM
fi

# move the file
mv $FILE $CUSTOMERS/$CUSTNUM/


------------------


Anilrgowda is offline   Reply With Quote