doc_jay
asked on
move all files from directories and subdirectories to folder
Hi,
I need some help in creating a .sh script where it will go through my /mnt/CVSSTank/dicom/hold directory, including the many sub-directories with it and move all of the files it finds to the path /mnt/CVSSTank/dicom/hold1. When it is done moving the files, it would be nice if it deletes the sub-directories within /mnt/CVSSTank/dicom/hold -
thanks!
I need some help in creating a .sh script where it will go through my /mnt/CVSSTank/dicom/hold directory, including the many sub-directories with it and move all of the files it finds to the path /mnt/CVSSTank/dicom/hold1.
thanks!
ASKER
got an error with this:
cvssarch:/mnt/CVSSTank# sh test.sh
rsync: change_dir "/mnt/CVSSTank/dicom/hold/ mnt/CVSSTa nk/dicom" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
test.sh: /bin/mail: not found
cvssarch:/mnt/CVSSTank#
Thanks for looking--
cvssarch:/mnt/CVSSTank# sh test.sh
rsync: change_dir "/mnt/CVSSTank/dicom/hold/
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]
test.sh: /bin/mail: not found
cvssarch:/mnt/CVSSTank#
Thanks for looking--
ASKER
okay I got it to run... just missed a 'space':
Thanks for your help on this --
this actually places a 'hold' directory in inside of my 'hold1' directory. Is there a way to change it so that it so that it only moves the files that it finds inside '/mnt/CVSSTank/dicom/hold/ ' and its many sub-directories to 'mnt/CVSSTank/dicom/hold1' ? I don't want to retain the path, so in other words, I don't want any sub-directories moved over, only the contents of the 'hold' directory and the sub-directories with it.
Thanks
Thanks for your help on this --
this actually places a 'hold' directory in inside of my 'hold1' directory. Is there a way to change it so that it so that it only moves the files that it finds inside '/mnt/CVSSTank/dicom/hold/
Thanks
if [ -e /mnt/CVSSTank/dicom/hold1 ]; then
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold /mnt/CVSSTank/dicom/hold1 > /var/log/backuplog.txt
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
/bin/mail -s "my backedup files " abc@abc.com < /var/log/backuplog.txt
Was this comment helpful?
Yes No
santoshmotwani:
if [ -e /mnt/CVSSTank/dicom/hold1 ]; then
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold /mnt/CVSSTank/dicom/hold1 > /var/log/backuplog.txt
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
Yes No
santoshmotwani:
if [ -e /mnt/CVSSTank/dicom/hold1 ]; then
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold /mnt/CVSSTank/dicom/hold1 > /var/log/backuplog.txt
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
there is a space between
/mnt/CVSSTank/dicom/hold (space) /mnt/CVSSTank/dicom/hold1
/mnt/CVSSTank/dicom/hold (space) /mnt/CVSSTank/dicom/hold1
if [ -e /mnt/CVSSTank/dicom/hold1 ]; then
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold/* /mnt/CVSSTank/dicom/hold1 > /var/log/backuplog.txt
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
try this
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold/*
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
try this
ASKER
that only copied the contents of '/mnt/CVSSTank/dicom/hold' which included a lot of sub-directories. So, your last attempt didn't work.
All of the files within '/mnt/CVSSTank/dicom/hold' are '.dcm' files. Is there any way you could write a script that does a 'find' of all '.dcm' files within '/mnt/CVSSTAnk/dicom/hold/ ' and all of the sub-directories and then 'move' them to the '/mnt/CVSSTank/dicom/hold1 ' path? After that could it delete all of the sub-directories within '/mnt/CVSSTank/dicom/hold' ? I also liked that log file idea you had.
Thanks
All of the files within '/mnt/CVSSTank/dicom/hold'
Thanks
if [ -e /mnt/CVSSTank/dicom/hold1 ]; then
rsync -av -r --remove-source-files /mnt/CVSSTank/dicom/hold/* /mnt/CVSSTank/dicom/hold1 > /var/log/backuplog.txt
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
Hi this will copy everything under HOLD including sub- directories. It will also delete all the files , but m not certain about directories.
I tested it on my PC
rsync -av -r --remove-source-files /mnt/CVSSTank/dicom/hold/*
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
Hi this will copy everything under HOLD including sub- directories. It will also delete all the files , but m not certain about directories.
I tested it on my PC
ASKER
this did not work either. All it did was copy all of the sub-directories inside of /mnt/CVSSTank/dicom/hold to /mnt/CVSSTank/dicom/hold1.
Is there anyone else who might have any ideas, particularly one that does not include 'rsync'?
Here is my idea of how the script could be written:
'All of the files within '/mnt/CVSSTank/dicom/hold' are '.dcm' files. Is there any way you could write a script that does a 'find' of all '.dcm' files within '/mnt/CVSSTAnk/dicom/hold/ ' and all of the sub-directories and then 'move' them to the '/mnt/CVSSTank/dicom/hold1 ' path? After that could it delete all of the sub-directories within '/mnt/CVSSTank/dicom/hold' ?'
thank you all
Is there anyone else who might have any ideas, particularly one that does not include 'rsync'?
Here is my idea of how the script could be written:
'All of the files within '/mnt/CVSSTank/dicom/hold'
thank you all
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
rsync -a -u -v -e --delete-after /mnt/CVSSTank/dicom/hold/m
else
echo "USB Disk not mounted /mnt/CVSSTank/dicom/hold1 " > /var/log/backuplog.txt
fi
/bin/mail -s "my backedup files " abc@abc.com < /var/log/backuplog.txt