?
Solved

Script to Find and combine multiple files into one on a move

Posted on 2013-10-28
4
Medium Priority
?
430 Views
Last Modified: 2013-10-28
I am running into a issue trying to come up with a script (.bat preferably but not absolute) file. I think the issue is finding the right terms to search for.

What I need is to search a directory for certain files that day that begin with similar text (one day there may be 4 files and the next there may be 10), grab all those files and move them to a different location and concatenate them. The trick is they need to all be combined into one file and given a different name.

I know it will be some type of move function and maybe grabs them a does some type of append... but not real sure.

Example:
Script runs
Grabs files from \\server\share1 named fileAB1.txt, fileAB2.txt, fileAC1.txt (so any files with fileA*.txt )
Moves the files to \\server2\share2 and combines the txt and leave a single file named CombinedA%date%.txt


These will all be text files.

thanks ahead of time.
0
Comment
Question by:ChesterfieldFire
  • 2
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 39605862
This realtively easy with the copy command, which allows concatenation.

So you can get all the files starting with say ABC and move them to a new location with a copy and then a delete, as in:

copy C:\dir1\abc*.* D:\dir2\newfile.txt
del C:\dir1\abc*.*

Make sense?

~bp
0
 

Author Comment

by:ChesterfieldFire
ID: 39605890
I will give it a test now. Thanks!
0
 

Author Comment

by:ChesterfieldFire
ID: 39605912
Awesome thanks Bill. Perfect. I knew it would be something I just could not search properly, but that seemed really easy :)
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39605935
Welcome, glad that helped.

~bp
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

809 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