We help IT Professionals succeed at work.
Get Started

Copy files WITH verification process for .sh script

weklica
weklica asked
on
514 Views
Last Modified: 2012-05-10
I have a directory with many sub-directories.  Each sub-directory contains thousands of files (for a total of 3.5 million).  I want to move each file to a single destination directory (remove from sub-directories).  However, a process runs on files received so I don't want to dump millions of files at once.  I would prefer that it move files from the source to the destination in a bit of a controlled fashion as follows:

Instead of just blasting them through and waiting for 10 seconds to loop as indicated in the script I pasted below, is it possible to have a file move and not have the next file move until the last one is gone from the new destination folder?  The destination folder is a cache folder.  The files there will not remain very long.  Once processed, they are moved again.  So, I would like to move each file from /Users/Shared/Source to /Users/usrnm/Documents/Test as indicated in the script below, but I don't want it to move each next file until it verifies that the file it just moved into /Users/usrnm/Documents/Test is no longer present.  So, sort of a check and balance control.  move all files from A to B, but don't proceed until each last file disappears from B.

Thanks in advance!
#!/bin/sh
while :
do
cd "/Users/Shared/SOURCE"
sudo mv * /Users/usrnm/Documents/Test
 sleep 10
done

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE