Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:42:47+00:00 2026-05-31T10:42:47+00:00

I have a folder full of .tex files and I would like to write

  • 0

I have a folder full of .tex files and I would like to write these file names to file, each inside an identical wrapper.

For example, let’s say that I have a folder with three .tex files A.tex, B.tex, and C.tex, although the file names don’t follow a simple pattern. These .tex files are tables and I would like to wrap them to get \begin{table} \input{A.tex} \end{table} and so on.

My first thought was that there could be a LaTeX solution, but looking around at TeX SE it seems that this may be better handled in a Vim (specifically the third answer here). Or is this a task better handled by Perl or some other scripting language? (I have limited Perl knowledge, but this would motivate me to learn more). Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:42:48+00:00Added an answer on May 31, 2026 at 10:42 am

    In case of filenames that do not contain newline characters, the issue can be
    easily solved in Vim script:

    :call append('.', map(split(glob('*.tex'), '\n'), '''\begin{table} \input{''.v:val.''} \end{table}'''))
    

    or

    :let fmt = '\begin{table} \input{%s} \end{table}'
    :call append('.', map(split(glob('*.tex'), '\n'), 'printf(fmt, v:val)'))
    

    The commands above uses the glob() function to collect the list of filenames
    matching given wildcard. Resulting set of filenames is represented as
    a string containing paths separated with newline characters. Using the
    split() function, the string is broken down into list, which is processed by
    the map() function to format filenames according to desired text template.
    Then, strings from this list are inserted below the current line with the
    append() function.

    Another way of populating a list of filenames in a buffer is to insert output
    of system directory-listing command through the :read! command,

    :r!ls *.tex
    

    In order to format the list as necessary, run

    :'[,']s/.*/\\begin{table} \\input{&} \\end{table}/
    

    immediately after executing the previous command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder full of zipped files (about 200). I would like to
I have a folder full of Windows .URL files. I'd like to translate them
I have a folder full of SWF files. Each SWF is its own animation.
I have a folder with two files inside; the java .class file and the
I have a folder full of 100-odd Access97 files. I need to update them
I have a folder full of files and I want to search some string
I have a folder full of html files created for a Kindle ebook. The
I have folder structure and I would like to create JSON objects based on
I have a folder with some dotfiles I would like to make symlinks for.
I have a folder with full of dump files as dumpA.sql, dumpB.sql, etc. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.