Search multiple folders and muiltiple files and combine to single file

 I want to search multiple folders for muliple files and combine to single file name. The files I'm searching have same format, but where named
differently in each of there processes. Now I want to combine based upon -SearchFor .. I'm having a problem with -Filter $SearchFor
Code:
Function Search-Files{
Param([String[]]$Locations,[String[]]$SearchFor, $AppendTo)
Begin
If(-Not (Test-Path $AppendTo)){New-Item $AppendTo -ItemType File -Force}
Process
ForEach($Location in $Locations)
$Files = Get-ChildItem -Path $Location -Filter $SearchFor -Recurse
ForEach($File in $Files)
Get-Content -Path $FIles.FullName | Out-File $AppendTo -Append
End{}
Search-Files -Locations "\\servera\public\t1\usa\saleshist\","\\serverb\public\t2\usa\saleshist\",-SearchFor "dodetail-cm.txt","somstr.txt",-AppendTo "\\virt1\Saleshist_data_load_files\saleshdr.load.csv"

I think you might want to use -Include instead of -Filter.  Your -Include parameter accepts wildcards, i.e. *.docx or *somstr.txt
Your command to actually append the content should be:
Get-Content -Path $File.FullName | Out-File $AppendTo -Append
You had $Files.FullName which might behave unexpectedly, if at all.
Your actual command has several issues.
Search-Files -Locations "\\servera\public\t1\usa\saleshist\","\\serverb\public\t2\usa\saleshist\" -SearchFor "dodetail-cm.txt","somstr.txt" -AppendTo "\\virt1\Saleshist_data_load_files\saleshdr.load.csv"
You had commas following the lists of locations and searchfor terms, did that even work? Without seeing your source files or your target file I can only advise you so much, but ideally you would import-csv and export-csv.  Depending on the contents,
you may be able to get away with get-content and out-file though.
I hope this post has helped!

Similar Messages

  • Search multiple folders for files with same name and create single file

     I have a project where I need to search multiple folders for a file name and when found append data from each file to a single input file.
     Example
    root folder to start search
    \\servera\sales
    \\servera\it\salesa\cmmstr.txt
    \\servera\it\salesb\cmmstr.txt
    \\servera\it\salesc\cmmstr.txt
     I need to create a a single cmmstr.txt on the root folder. I would like it to be able to run this with parms to pass in folders to search and file names to search and single file name to create. I'm going to have a least 10 differnt files to
    search for and create output file for. The folders to search
    will somewhat be static.
     Thanks.

    I tested this out on my own seat and I think it should work for you. I wrote it as a function, all you have to do is pass the root folders you want to search and the file your looking for. The function will then search that directory and all sub directories
    for that file name. you will also have to provide it a file to append to, if the file dosen't exists the function will create it. If you run into an issues let me know and the links Mike
    Laughlin posted are a great resource.
    Function Search-Files{
    Param([String[]]$Locations, $SearchFor, $AppendTo)
    Begin
    If(-Not (Test-Path $AppendTo)){New-Item $AppendTo -ItemType File -Force}
    Process
    ForEach($Location in $Locations)
    $Files = Get-ChildItem -Path $Location -Filter $SearchFor -Recurse
    ForEach($File in $Files)
    Get-Content -Path $FIles.FullName | Out-File $AppendTo -Append
    End{}
    Search-Files -Locations "\\Server1\c$\Temp", "\\Server1\c$\Test1" -SearchFor "Install.cmd" -AppendTo "C:\Temp\Search.log"

  • Will lightroom search multiple folders and subfolders for keywords?

    Will lightroom search multiple folders and subfolders for keywords?

    Yes, if you select the folders in the explorer pane to the left in library mode,

  • How to Search Multiple Folders?

    I am using a new machine with 10.7.2 Lion and I'm unable to do something I used to do on 10.4.11 Tiger, that is, search multiple folders simultaneously in Finder. To be clear, in a Finerd window, I was able to hit command-f and the current folder name would appear along with a button that said "Others." Clicking that would allow me to select any number of additional folders to include in my search. There isn't an "Others" button in Lion! What happened? Did the Lion developers get Lost?

    Greg,
    There's one way of doing this that's even easier than before.
    Use a Spotlight Search, one of the best OSX features ever. Simply press CMD-space, and you'll get a small window. Type in your search criteria, and Spotlight will automatially list all of the hits on your computer - without even pressing enter.
    If you're searching, say, using Safari, CMD-F will let you search for all the hits on the site you're on, and highlight them. Press Enter to cycle through the hits, if you have any.
    Otherwise, use Spotlight for your system search needs.

  • How and where can I combine several pdf files?

    I have written a Guide Book for Music Teachers in Word, converted it into a pdf file and would now like to insert sheet music files written with Sibelius Notation Program which have also been converted into pdf files, since they are otherwise not compatible with Word. How and where can these diverse pdf files be combined?

    First, make sure you open Acrobat, and not Adobe Reader.  It's a common mistake.
    From Acrobat, use File | Create | Combine Files into a Single PDF:
    On the next panel you can select the files you want to combine, rearrange them, etc., and finally click Combine.
    P.S. your menu may look slightly different, as we may not be using the same Acrobat version.

  • Is it possible to package PDF files so that a single file appears as if it is located in multiple folders?

    I am currently working on a project for a client that contains numerous hyperlinked files. As an overview, there is a guidebook that contains several sets of activities. Each set of activities calls on two or more individual files that reside in folders outside of the guidebook. Different sets of activities might call on the same individual file. Rather than duplicate it across multiple folders, my preference would be to have it reside in a single location, but be mirrored in each folder it is associated with.

    Not sure I see the problem. The file only needs to be in one place, you can link between folders.

  • My Creative Cloud details at top right dont show up, the files dont go into single file mode

    I really need help. I have uploaded my files from Adobe Ideas to the creative cloud and now nothing downloads and when I click on the files they go to a blank page. My account details at the top right have been replaced by ellipses. Also, since "archive" actually means "delete" I have accidentally premanently deleted all my files. I though it wouldnt be a problem as I had the files on my Adobe Ideas app on my iPhone but to my surprise it had deleted all my Ideas files on my phone permanently too. So here I am with nothing working and hours of work gone and this was the first time I really used the creative cloud to store my files and just started using the Ideas app too. Please help me.
    Thanks

    This issue should now be resolved. If you are still experiencing a problem please reply.

  • Multiple folders created by iCloud and MobileMe in Outlook

    iCloud and MobileMe have created a slew of calendar and contact folders in my Outlook.  Several problems were created. 
    The default calendar and contact list are not the ones opened when Outlook launches.  I have to manually select the iCloud folder in each.  The iCloud contact list is identical to the one that used to be my personal folder contact list (this is good).  The default file folder in Outlook is still the personal (no contacts shown), but I get some scary warning from Outlook if I try to change it to iCloud.
    The personal folder on my computer (even though it exists) shows NO contacts and no calendar entries.  It should show several thousand contacts and be identical to my iCloud contact list (at least starting off).
    Outlook will not let me delete the MobileMe generated calendars or contact lists.  The delete option is grayed out.  In most cases I cannot even open the calendars that MobileMe created.  I get a “The set of folders cannot beopened.  The information store cannot be opened”.
    Any ideas?

    The problem is...I can find each individual folder by using "show in finder"...but I can't find where they all are! I think they may be the thumbnails from iCloud Photos??

  • Combining multiple files together to make single file

    My Canon camcorder only does a movie file up to 2 GB, then it starts a new file.  I have a speech and it made 3 files.  When I put them back together, they are still not smooth, you can definitely tell whre one ends and the next begins.  How can I out it back together as the whole thing?
    Wayne

    Wayne,
    IIRC, Canon ships software with their cameras, to "stitch" those segmented files back together. I would investigate using that. Otherwise, you might need to do some precise Trimming to get things to look smooth. Check the disc that shipped with your camera.
    Good luck,
    Hunt

  • Append the file and print the output in a single file in column manner

    Hi All,
    I have 2 files in UNIX.
    File1.txt
    NAME SAL
    Albert $4567
    Monali $7892
    Raj $8521
    File2.txt
    DOB
    12-JUL-1986
    5-Aug-1978
    13-MAR-1958
    so i apped both the file
    cat file1.txt file2.txt>>file3.txt
    The output of file3.txt was:
    NAME SAL
    Albert $4567
    Monali $7892
    Raj $8521
    DOB
    12-JUL-1986
    5-Aug-1978
    13-MAR-1958
    But i need the output below
    NAME SAL DOB
    Albert $4567 12-JUL-1986
    Monali $7892 5-Aug-1978
    Raj $8521 13-MAR-1958
    Could you please help me to resolve
    Edited by: user10069916 on Sep 6, 2012 12:07 AM

    $ man paste
    $ cat file1.txt
    NAME SAL
    Albert $4567
    Monali $7892
    Raj $8521
    $ cat file2.txt
    DOB
    12-JUL-1986
    5-Aug-1978
    13-MAR-1958
    $ paste file1.txt file2.txt >file3.txt
    $ cat file3.txt
    NAME SAL        DOB
    Albert $4567    12-JUL-1986
    Monali $7892    5-Aug-1978
    Raj $8521       13-MAR-1958
    $

  • Custom thumbnail for a file type, not a single file

    I understand that when I upload an asset to the DAM of a file type for which CQ5 doesn't support thumbnail generation (Excel .xls and .xlsx, in my case), CQ5 will use a default dogeared-page icon for the thumbnail.  it also writes an error-level message to the log to the effect that it can't generate a thumbnail.  E.g.,
    15.10.2012 12:03:47.078 ERROR [JobHandler: /etc/workflow/instances/2012-10-15/model_1135358760340484:/content/dam/FY06NIVDetailTable1.xls/jcr:content/renditions/original] com.day.cq.dam.commons.handler.AbstractAssetHandler createThumbnails: cannot create thumbnails for asset [/content/dam/FY06NIVDetailTable1.xls], failed loading graphical representation for rendition [/content/dam/FY06NIVDetailTable1.xls/jcr:content/renditions/original].
    The error message is mostly harmless, but I would like to prevent it.
    And I understand that I can add a thumbnail after the fact.  But despite the language in the document, apparently this thumbnail does not apply to subsequent uploads (for all files of the same type).
    Is there a way to establish a thumbnail image that applies to subsequent uploads?

    Hi David,
    Thumbnail upload (or for that matter any rendition upload) is specific to that image and it will not apply to set of images.
    If we want to apply some custom thumbnail instead of the default one either we need to override the default image or custom workflow step is required.
    If we override the default image it will apply acroos the DAM.
    Regarding custome workflow step. This step will be added after thumbnail creation step in DAM Update Asset workflow(this wf is responsible for creating all renditions). In this workflow step you can check whether thumbnail is created or not if not create thumbnail of your desire.

  • Read multiple files and write data on a single  file in java

    Hello,
    I am facing difficulty that I want to read multiple files in java and write their data to a single file. Means Write data in one file from multiple files in java
    Please help me out.
    Naveed.

    algorithm should be something like:
    File uniqueFile = new File();
    for (File f : manyFilesToRead)
       while (readingF)
           write(dataFromF, intoUniqueFile);

  • How to Combine an .m2v and and an .AC3 into one QT.mov file

    A few years ago I converted a .mov file into an .m2v and an .AC3 using Compressor 1.2 (that was for DVD Studio Pro 3.0). I lost the .mov and now need to combine the two files into one QT .mov file. How can I do that please?
    I have QT 7.1 3 in OS 10.3.9 and also the QT that came with OS 10.5.8 (I can run either OSs.) (I know that the combined file will be of poorer quality compared to the original .mov). I have Aimersoft Total Media Converter 2.0.4 which can convert video from one form to another, but it can't combine (at least I don't think so).

    I lost the .mov and now need to combine the two files into one QT .mov file. How can I do that please?
    If you don't have software to do this directly, basically you would have only two other options. The first would be to mux the M2V and AC3 files and then convert the "muxed" file using a compatible converter. The second, would be to convert the audio and video files separately and merge the converted files in a video editor, QT Pro, GarageBand, or a similar application.

  • How would I import multiple Roadrunner emails each with multiple folders and continue to use my Roadrunner email to send and receive?

    How would I import multiple Roadrunner emails each with multiple folders into Apple Mail and continue to use my Roadrunner email to send and receive from within Mail?

    Try this.. Click the first in the CC field hold Shift, Click the Second Third, Fouth, Fifth and so on... click right Mouse select add to Contacts.

  • Picking files from multiple folders based on name send to destination folde

    Hi,
       I want to pick multiple files from multiple folders with one root folder. Based on file name I want to send it to diffirent folders. No need to go for message mapping. Can anyone suggest me.
    Thanks & Regards,
    Prasad Kotla.

    Hi Prasad,
    to pick the files from multiple source directory, can use "Advance Selection for Source File" in Sender CC.
    If you wand to develop a Scenario without Message mapping, develop a scenario as "Sender as Virtual receiver"
    This option is available in Sender agreement, just give the dummy name for Msg Interface and Namespace, Name defined should be same in Rec Agreement.
    Develop only: Sende CC, Receiver CC, SA, RA
    No need to develop ID and RD as no mapping is involved.
    If u want to send the files to different folders of receiver side, just develop the adapter module which changes the directory based on the sender filename.
    If the sender and receiver directory is same than check the "adapter specific Msg Attribute"  and "directory" checkbox in both the sender and receiver CC. in this case no need to develop Custom module for changing the directory. files will be automatically placed in the path they were picked from  sendor directory
    appreciate if useful
    regards,
    chandra shekhar

Maybe you are looking for

  • Cannot get distcc/pump to work

    I have two machines on a GigaLAN both running distccd.  1) Workstation (Intel i7-3770K) with 8 logical CPUs. 2) Laptop (Intel C2D) with 2 logical CPUs. On my workstation: % cat /etc/distcc/hosts localhost/9,cpp,lzo 192.168.0.102/3,cpp,lzo On my lapto

  • Dump while saving sales order

    Hi, I was doing my config from quite a while and was able to save sales orders normally. All of a sudden, I am now unable to save any sales orders. It is throwing a dump while I am trying to save the sales order. The dump details are provided below.

  • Exporting to DV tape with a DVX 100a

    I am trying to export a project from FCP to DV tape using my DVX 100A camera as a deck (I know that it would be better to use a regular deck but that's not in the budget right now so please no need to offer advice about using a regular deck). I have

  • What is the best format for a new video editing hard drive?

    Hello, I would like to know how to properly format a new 2 TB Hitachi hard drive that I have for my early 2008 Mac Pro that will be installed in drive slot 3. Information at the following link explains that: "Journaling is essential for OS disks (boo

  • How to create purchase Requisitioner

    Dear sir how to create purchase Requisitioner please provide setting