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

  • SEARCH
  • Home
  • 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 9076179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:03:10+00:00 2026-06-16T19:03:10+00:00

I have IMDB collection from INEX, which consist few million XML files in few

  • 0

I have IMDB collection from INEX, which consist few million XML files in few thousand directories with structure like this:

- actors
-- 000
--- person_1000.xml
--- ...
-- 001
--- person_1001.xml
--- ...
...
- movies
-- 000
--- 10000.xml
--- ...
...

I need to convert these files to TRECTEXT format, which is

<DOC>
 <DOCNO> document_number </DOCNO>  
 <TEXT>  XML file goes here. </TEXT>  
</DOC>

Where document_number should be file name without extension, e.x. person_1000.xml -> person_1000 and contents of XML file should be wrapped in tags.

I assume I need some script which wraps every XML file in collection in , and tags as shown above and overwrites original file. Could you help me please?

  • 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-06-16T19:03:11+00:00Added an answer on June 16, 2026 at 7:03 pm

    I’m not familiar with TRECTEXT format, but here’s a one-liner using Perl that should do what you want:

    find . -type f -name "*.xml" -exec perl -MFile::Basename -0777pi.bak -e 's#(.*)\n#"<DOC>\n <DOCNO> ".basename($ARGV,".xml")." </DOCNO>\n <TEXT> ".$1." </TEXT>\n</DOC>\n"#es' {} \;
    

    Obviously remove the .bak extension if you don’t wish to keep any backup files. Please let me know if you have any problems. Cheers.


    Update, as per comments:

    find . -type f -name "*.xml" -exec perl -MFile::Basename -0777pi.bak -e 's#.*#"<DOC>\n <DOCNO> ".basename($ARGV,".xml")." </DOCNO>\n <TEXT> ".$&." </TEXT>\n</DOC>\n"#es' {} \;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
i would like to get the poster image url using php from imdb from
I have the following xml file as output from a program: <?xml version='1.0' encoding='ISO-8859-1'?>
I have written a web application which extracts data from a DB and displays
Here's what I am trying to accomplish - I have about a million files
I have (from the imdb database) a casts table and a movie table. I'm
I have several thousand text strings where the IMDB occures in fairly random positions,
I have a file (ratings.lst) downloaded from IMDB Interfaces. The content appears to be
I have a very large set of string URL patterns like {http://www.imdb.com, http://www.amazon.com ,...}
I have this XML file: <movie id = 0> <Movie_name>The Shawshank Redemption </Movie_name> <Address>http://www.imdb.com/title/tt0111161/

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.