Solved

need script to copy files in order

Posted on 2002-03-25
2
207 Views
Last Modified: 2010-04-21
I have many files in a directory that are named as follows

QDV_200203191143190276.txt
QDV_200203191143190307.txt
QDV_200203191143190313.txt

Basically having the naming convention

QDV_YYYYMMDDHHMISSmmmm.txt

I need to copy these files one by one to another directory, where they will be read in by another program.  The program reading them in, polls at 1 second intervals, so if I could copy them in at 1.5 or 2 second intervals (preferrably 1.5) to the new directory, that would be great.

Just use directory1/directory2 naming conventions...I can change it to what I need it to be.

Thanks

mboss
0
Comment
Question by:mboss
  • 2
2 Comments
 
LVL 4

Expert Comment

by:newmang
ID: 6895368
What about something like the following

for FILENAME in `ls QD*.txt`
  do
     cp -f dir1/$FILENAME dir2/$FILENAME
     sleep 2
  done
exit

If you want them read in name order then the first line would read

for FILENAME in `ls QD*.txt | sort`

Note the tick marks are backticks....

Cheers - Gavin
0
 
LVL 4

Accepted Solution

by:
newmang earned 300 total points
ID: 6895373
What about something like the following

for FILENAME in `ls QD*.txt`
  do
     cp -f dir1/$FILENAME dir2/$FILENAME
     sleep 2
  done
exit

If you want them read in name order then the first line would read

for FILENAME in `ls QD*.txt | sort`

Note the tick marks are backticks....

Cheers - Gavin
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question