Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A client of us, is going to transfer the files to our server. I need to check if the files exist in that inbound directory and if they are , move them to a different directory so I can read them from my code. I need to write a shell script for this. How do I iterate through files in that inbound directory?

share|improve this question

Maybe you want to check they are not in use...

find INBOUND -type f -mmin 10 -exec mv '{}' THEOTHERPLACE ';'

-mmin n : file's data was last modified n minites ago

share|improve this answer

make a cronjob which does this:

find INBOUND -type f -exec mv '{}' THEOTHERPLACE ';'

the tricky part is to find out, if a file is not yet finished (eg, someone is still uploading). you could play around with fuse to find out, if someone is still writing to a file and ignore that file (for now).

share|improve this answer

Write your script around rsync and let it do the work. It does intelligent synchronization of files - locally or on a remote server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.