Copy Contents of Multiple Text Files to Clipboard

Page 1 of 2 12 LastLast

  1. Posts : 521
    Win7 Pro X64, Win10 Pro x640
       #1

    Copy Contents of Multiple Text Files to Clipboard


    Does anyone know how to modify the tutorial "Copy Contents to Clipboard" through some sort of command or bat file to copy the contents of multiple text files at once to the clipboard, each file separated by lines/space or something?

    Add Copy Contents to Clipboard to Context Menu in Windows 10

    @dalchina you helped out with an autohotkey script for enhancing search to the context menu, how would you do the same for multiple text files?

    Thanks!
      My Computer


  2. Posts : 43,013
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    It is actually interesting that selecting mutiple files and using (e.g.) that script to search does open three tabs in Firefox.

    The problem becomes how one would handle the processing of those files in sequence to append them to one destination rather than 3. I have no idea how that would be done.

    Given that it's a particularly niche specification, my immediate reaction is it's not one I'd spend time trying to solve.
      My Computers


  3. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #3

    Hello @bamajon1974,

    bamajon1974 said:
    Does anyone know how to modify the tutorial "Copy Contents to Clipboard" through some sort of command or bat file to copy the contents of multiple text files at once to the clipboard, each file separated by lines/space or something?
    If I remember correctly I did something similar a few years ago using a Batch file. I think it turned out to be something simple like [ with the correct suffix added of course ] . . .
    Code:
    copy file_name1 + file_name2 + file_name3 target_file
    If you wanted to copy all the files in a particular folder for example, you could use a loop.

    I hope it helps!
      My Computer


  4. Posts : 43,013
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #4

    It's more complicated than that.

    n files could be selected where n is variable.

    In a context menu, the parameter passed is the full path of the item selected.

    Thus n separate instances of the program launched from the context menu somehow have to append either the path or the contents of the file selected to one destination.

    You would somehow have to take all those separate paths and process them in turn in a loop as you say, which appears to require n instances of scrip a triggered from the context mennu to result in data being processed by a single script, script b.
      My Computers


  5. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #5

    In a pure simplistic form as an example, I suppose you could do something like this . . .
    Code:
    set "tmp1=file_name1.txt"
    set "tmp2=file_name2.txt"
    set "tmp3=file_name3.txt"
    set "target=target_file.txt"
    
    type "%tmp1%" >> "%target%"
    echo.         >> "%target%" & echo ========== NEXT FILE ========== >> "%target%" & echo. >> "%target%"
    type "%tmp2%" >> "%target%"
    echo.         >> "%target%" & echo ========== NEXT FILE ========== >> "%target%" & echo. >> "%target%"
    type "%tmp3%" >> "%target%"
    echo.         >> "%target%" & echo ========== NEXT FILE ========== >> "%target%" & echo. >> "%target%"
    I actually did something similar to this yesterday where I had to dump a file into the tmp directory and then copy the contents into a specific location in a new file!
      My Computer


  6. Posts : 521
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #6

    Situations like this is when I wish I took a basic coding class in college. I know next to nothing about scripting, coding or programming. The script that @Paul Black posted is something like what I want but I agree with @dalchina that some sort of loop is needed when an arbitrary number of files are selected. I just don't know the format and syntax.

    There used to be tutorials on the older versions of these forums that used a batch file to right click to copy directory contents of an arbitrary number of files/folders to a text file. Would that syntax work similarly?

    Alternatively, I did find a suitable solution posted below that copies the contents of multiple files to the clipboard using the SendTo menu with a program called ClipOut. I will see if I can use it to in the right-click menu as well.

    How to Send the Contents of the Clipboard to a Text File via the Send to Menu
      My Computer


  7. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #7

    Hello @bamajon1974,

    Are you talking about something like this => Add 'Copy Contents to Clipboard' to Context Menu in Win 10

    I hope this helps!
      My Computer


  8. Posts : 521
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #8

    Paul Black said:
    Hello @bamajon1974,

    are you talking about something like this => Add 'Copy Contents to Clipboard' to Context Menu in Win 10

    I hope this helps!
    Yes but the registry modification/command in the tutorial only works for one file. I want to be able to copy the contents of an arbitrary number of text files to the clipboard rather than just one.

    Does that make sense?
      My Computer


  9. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #9

    Hello @bamajon1974,

    bamajon1974 said:
    Yes but the registry modification/command in the tutorial only works for one file. I want to be able to copy the contents of an arbitrary number of text files to the clipboard rather than just one.
    Creating a batch script based on my sudo code will do what you want. Once you have the <target> file setup, you can copy as many other files into it that you want.

    The loop would look something like this . . .
    Code:
    for %%f in (*.txt) do type "%%f" >> target.txt
    I hope this helps!
      My Computer


  10. Posts : 521
    Win7 Pro X64, Win10 Pro x640
    Thread Starter
       #10

    Paul Black said:
    Hello @bamajon1974,



    Creating a batch script based on my sudo code will do what you want. Once you have the <target> file setup, you can copy as many other files into it that you want.

    The loop would look something like this . . .
    Code:
    for %%f in (*.txt) do type "%%f" >> target.txt
    I hope this helps!
    Ok now that helps. If I am reading this code correctly, the output is to a text file right? And I want to preface your code above with the code from the registry modification?
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:15.
Find Us




Windows 10 Forums