Menu

Help needed saving a list as different files

2009-01-07
2012-11-13
  • Marco Cevoli

    Marco Cevoli - 2009-01-07

    Hi,

    First of all, I am no expert in using Notepad++, so I don't even know if what I am asking is possible or not. I think it's very simple, provided you know how... :-)

    I have a relatively short list (less than 1000 items) of movie titles in a txt files, just like that:

    The General (1927)
    Dracula (1931)
    Frankenstein (1931)
    The Mummy (1932)

    I would like to generate an empty text file for each item.

    "The General (1927).txt"

    If you are interested why I want to do this, please take a look here: http://www.xbmc.org/wiki/?title=HOW-TO:_Catalog_and_use_lookups_on_your_offline_DVD/CD_movie_library_\(via_fake_files)

    Thanks a lot for your help.

    Marco Cevoli
    Qabiria
    http://www.qabiria.com

     
    • Gadrin

      Gadrin - 2009-01-11

      You're welcome Marco,

      The DOS command line (actually the command interpreter) has a help file. On my system it's:

      C:\WINDOWS\hh.exe C:\WINDOWS\Help\ntcmds.chm::/ntcmds.htm

      There's a section called "Command shell overview" that has some details in it..

      " Notes

      The ampersand (&), pipe (|), and parentheses ( ) are special characters that must be preceded by the escape character (^) or quotation marks when you pass them as arguments. "

      So if you get some weird/unusual quirks in your scripts/lines you can take a look at those.

      >

       
    • Peter Bittner

      Peter Bittner - 2009-01-08

      Sorry in advance for this answer, but this is what came into my mind immediately: (Has nothing to do with Notepad++, unfortunately. Ask me if you are interested and need more information.)

      Solution using Python:
      -> Save the following lines in a textfile and execute it with Python:

      # File: createdummyfiles.py

      import fileinput

      for line in fileinput.input("my-list-of-movies.txt"):
          filename = str((line) + ".txt"
          textfile = open(filename, "w")
          textfile.close()

       
    • Peter Bittner

      Peter Bittner - 2009-01-08

      ... with the last three line indented with spaces, obviously.  :-(

       
    • Gadrin

      Gadrin - 2009-01-09

      Sure, if your file is called "movies.txt" then open a DOS prompt and type the following. Make sure you're
      in the same folder as the "movies.txt" file...

      for /F "eol=; tokens=1* delims=," %i in (movies.txt) do @echo %i> %i.txt

      Assuming the contents are ONLY what you posted, you'll see the following files appear in the folder:

      Dracula (1931) .txt
      Frankenstein (1931) .txt
      The General (1927) .txt
      The Mummy (1932).txt

      Each will contain a single line of text, which is the line from the file.

      You can then turn the DOS command into a .BAT file and RUN it from the menus on Notepad++. I don't know how to create an completely empty file with DOS, but a similar method can be done with VBScript, where it just reads the contents of your file and creates empty files.

      >

       
    • Marco Cevoli

      Marco Cevoli - 2009-01-09

      Thank you very much, Peter. That means that I should install Python on my desktop pc. Eventually, I could do it. However, is there a way to achieve the same result in some standard office program? Yeah, this has nothing to do with Notepad++, sorry about that.

      :-)

      Regards

      Marco

       
    • Gadrin

      Gadrin - 2009-01-09

      Turns out you can create a blank file with DOS. Apparently "echo." (with a period after it does the trick).

      for /F "eol=; tokens=1* delims=," %i in (movies.txt) do @echo.> %i.txt

      gives me all blank files. Double-check for your project and let me know.

      >

       
    • Marco Cevoli

      Marco Cevoli - 2009-01-09

      Gadrin, thank you very much. I did that and, except for some minor errors caused by commas in the titles, it worked out perfectly! I assume that XBMC does not need really empty files, gonna try right now.

      Thank you for your help once again

      Ciao

      Marco

       
MongoDB Logo MongoDB