Skip to main content
Topic: Making a catalog of your NWC files (Read 37021 times) previous topic - next topic

Making a catalog of your NWC files

Do you have a large collection of NWC files on your computer? If so, you might want to try this tip for making a catalog of all of your NWC files.

The NWCINFO Tool:
The NWCINFO program is a console mode tool that can be used to extract information about NWC files. NWCINFO is available from the NWC downloads page. It is provided in a compressed ZIP package, so you have to manually extract its contents into a folder on your hard drive. In order to make it easier to work with console programs, a short folder location is recommended, such as C:\BIN. The rest of this tip assumes that you have extracted the NWCINFO tool into the C:\BIN folder of your hard drive.

Your NWC Collection:
If you have not already done so, now would be a good time to establish a separate location for your NWC collection. It is always a good idea to keep your files separate from your computer's application/program files. This makes it easy to find and backup all of your documents/files, without having to also backup all of your programs. In this tip, we assume that all of your personal documents, including NWC files, are located in a subfolder on your computer called C:\MyFiles.

Creating a NWC Song Catalog:

Starting a Console Session: The best way to work with the NWCINFO program is by opening a console from within Windows. Unfortunately, the best way to do this will sometimes depend on what version of Windows is installed on your computer. Start by looking in your Accessories section of the Start menu: Start -> Programs -> Accessories -> Command Prompt. If you do not see this command, look for an entry titled MS-DOS Prompt in the Start menu. If neither of these are present, try using the Start -> Run command. For Windows 95, 98, and ME, type Command the run box. For Windows 2000 and XP, type Cmd in the run box.

Building a Catalog: From the open console window, it is now possible to invoke a single command that will create your NWC file catalog, complete with the name of the NWC file, followed by its title and author. First, we should change our current working directory to the base location of all of our personal documents. We do this with the change directory (CD) command:

CD "C:\MyFiles"

Hint: The quotes are only really necessary if your actual folder name includes spaces. If your folder name includes spaces, simply quote the folder name whenever you use it in a command line.

Now, we create our NWC catalog by piping the result of a directory listing into the NWCINFO command, and saving the output into a catalog file:

dir /b /s *.nwc | "C:\BIN\NWCINFO" /list > NWC_Catalog.TSV

How does this command work? The "dir /b /s *.nwc" command lists all NWC files that are found within the MyFiles folder and any folders within the MyFiles folder. The vertical bar "|" is used to direct the output to the next command. The "C:\BIN\NWCINFO /list" command then reads the directory listing of NWC files, and then outputs a series of tab separated values (TSV) that make up your NWC catalog. The greater than sign ">" is used to direct the final output into a file named "NWC_Catalog.TSV". Each line in the TSV file describes one of your NWC files. There are three fields on each line. The first is the name of the NWC file, the second is the title of the song, and the last field is the author, as identified from File Info in NWC.

Browsing Your Catalog: Although you can view your TSV catalog with any text editor, it is easier to work with the results in a spreadsheet or database program. You might even have an appropriate viewer for your TSV file already installed on your computer. From the same console window, enter the following:

Start NWC_Catalog.TSV

This tells Windows that you want to view your new NWC catalog. A program suitable for viewing your catalog might open automatically. If it does not, you should try selecting either a spreadsheet or database program from the Open With box that appears. From within the viewer, you now can use the search and sort facilities of the viewer program to find and analyze portions of your NWC file collection.

Closing the Console Window: The best way to close the console window is by using the exit command. Congratulations, you have now mastered the art of using the command line within Windows.

See also:


Re: Making a catalog of your NWC files

Reply #1
...and even mastered advanced art of DOS command line!
Thanks for the new /list option of NWCINFO.EXE :-)

If you're at ease with the tip above, you may want to go further. Ready?

If you have NWC files in many directories and not only in (sub)directories of C:\MyFiles, then you could do the following command (from any directory):

dir /b /s C:\*.nwc | "C:\BIN\NWCINFO" /list > C:\MyFiles\NWC_Catalog.TSV
(compare with previous command).
Of course, the C:\MyFiles directory should be replaced by the name you want, and must already exist. If omitted, the .TSV file will be placed in the current directory.

You can repeat this with all your disk drives (C:, D:, ...), in that case the ">" sign should become ">>" if you want to add (concatenate) the results to the previous ones:
dir /b /s C:\*.nwc | "C:\BIN\NWCINFO" /list  > C:\MyFiles\NWC_Catalog.TSV
dir /b /s D:\*.nwc | "C:\BIN\NWCINFO" /list >> C:\MyFiles\NWC_Catalog.TSV
and so on.

If you're still at ease with all of this, you may want to look at the for form too to simplify the disk drives names, but this becomes more advanced DOS command!)

Re: Making a catalog of your NWC files

Reply #2
-
Batch commands (for %n in...) and batch files, even batch commands in batch files can be involved. ;)

In that case, replace the > (greater than) operator with a double one >> for your outpu files not to be overwritten at each time.
_

Re: Making a catalog of your NWC files

Reply #3
Is the NWC Info program also working with NWC 2 files?


Re: Making a catalog of your NWC files

Reply #5
Perfect.

Many thanks!

Re: I lost my Liszt...

Reply #6
Hi Everyone

Please remember that folder (directory) and file names containing spaces must be enclosed in quotes when working from the command line (which also includes batch files).  If the quotes are missing, the Command Interpreter sees the space as a delimiter, and what follows the space an argument.  Thus the folder C:\Documents and Settings is seen as C:\Documents (which does not exist) with and & Settings arguments.  Thus CMD.EXE reports file or directory not found.

This came in with Windows 95 and long filename support, and in my humble opinion something which Bill & Co should have fixed long ago!

Hope this helps

Bob Petty

Re: I lost my Liszt...

Reply #7
Hi Bob.

Quote
Please remember that folder (directory) and file names containing spaces must be enclosed in quotes when working from the command line

Yes, of course. And indeed this was my first though.
But in this case NWCInfo /list reads the list of filenames generated by piping the output of the dir command and parses each line as a filename. I have no control on it.
Luckily NWCInfo is aware of the problem of the blanks in the filenames and handles it correctly.
Not so for the non-ASCII letters.

Years ago I read something somewhere (vague enough? :-) about the problem of the command line commands outputting filenames in the OEM codepage while the windows GDI programs work with the ANSI (or, more recently, Unicode) charset.
Indeed, if I send the output of the dir command to a file, the filenames are in the OEM codepage.

I hoped in the command
Code: [Select · Download]
%ComSpec% /a /c dir /s /b *.nwc > foo
but the result is unchanged.

Using the command
Code: [Select · Download]
%ComSpec% /u /c dir /s /b *.nwc > foo
the result changes: the output file is empty! :-(

N.B. I'm using win2000, just in case...


Re: I lost my Liszt...

Reply #9
Hi Flurmy

Yes, you are right.  Windows 2000 and XP in the GUI support Unicode.  However, I think I am right in saying that 2K uses the ASCII character set at command level, i.e. characters 32 to 255 (20 to FF Hex).  If I get a chance I will test this in a 2K box at work and post back.

Kind regards

Bob Petty (UK)

Re: Making a catalog of your NWC files

Reply #10
I have only skimmed this lengthy thread to form an idea of what it's about.  I think it is how to list your NWC files by name.  If I'm wrong forgive me...

There's a very convenient little utility called Filegrab.exe from PC Magazine.  Go here to get it http://www.pcmag.com/article2/0,2817,1161099,00.asp

Quote
"When you launch FileGrab, you'll see an empty window ready to accept filenames from Explorer. For a quick demonstration of how it works, open an Explorer window (it's okay if the windows partially overlap), highlight a group of files, drag them over to FileGrab, and drop them into its window. Voilà! There's your file list.  ...You don't have to worry about anything happening to the files when you drop their names onto FileGrab. They'll stay right where they are; only the filename data is copied into FileGrab."

I've used it for years. It's truly that easy.   I got mine when it was freeware, but I see they sell it now, but it's cheap.   $7. plus change now, and well worth it.  It was written for Win 95 but runs on WinXP Pro.  I imagine it will probably run on Vista too but I can't promise.


Re: Making a catalog of your NWC files

Reply #11
I made some experiments and I can confirm that the problem is the mess windows does with filenames for compatibility reasons.

The easiest solution could be that Eric adds a call inside NWCInfo to the OemToChar function before opening the files when the switch /list is used.
But what would happen if someone prepares a file list "manually" and that list is already in the ANSI charset?
Exactly the opposite of what happens now.

Adding another command line switch to NWCInfo, e.g. something like /OEM, to enable the charset conversion could be a simple, fast and convenient solution to the problem.
Someone has a better idea?

In the meantime I opted for a quick (and dirty) solution like that (lets call it NWCList.bat) that seems to work fine:

Code: [Select · Download]
@echo off
echo Creating the list of the NWC files with its data
echo The results are in NWC_Catalog.TSV (tab-separated values)
echo N.B. The files .nwctxt are ignored
dir /b /s *.nwc | find /i /v ".nwctxt" | OEMToANSI | NWCInfo /list > NWC_Catalog.TSV
echo Done
pause

Of course, the juicy part is the line starting with "dir".
dir /b /s *.nwc prepares the list as usual (OEM charset)
find /i /v ".nwctxt" removes all the files *.nwctxt from the list
OEMToANSI is a small program I did to convert from locale codepage (OEM) to ANSI
NWCInfo /list > NWC_Catalog.TSV is the usual part.

If you want (and have time...) you can scan the full drive C: as already suggested: dir /b /s C:\*.nwc
With my big HD it's not a good idea.

If I'm right, I can not attach an executable here so it is downloadable from
http://rapidshare.com/files/167179223/NWCList.zip.html.
(N.B. It seems it's downloadable only 10 times and for 90 days. If we don't find a better solution I'll send it to Richard for the scripto)
Here I show the deplhi source code.

Code: [Select · Download]
program OEMToANSI;
{$APPTYPE CONSOLE}
uses
  Windows;
var
  S: string;
begin
  while not EOF(input) do
  begin
    readln(S);
    OemToChar(PChar(S), PChar(S));
    writeln(S);
  end;
end.

Wow! What seemed a trivial operation...

Rick, the wizard of scripts, do you have a cleaner solution?

N.B. Erik, I think that, as Rick said, this thread is in need of a little clean-up. Sorry for all my cluttering.

Re: Making a catalog of your NWC files

Reply #12
We will consider a better method for making a *.nwc catalog.

 

Re: Making a catalog of your NWC files

Reply #13
Quote
We will consider a better method for making a *.nwc catalog.


Eric, I keep my NWC files in separate folders by song name, about three levels down from the root of my C drive.  You would never know from the top level folder that it has any nwc files in it.  Each NWC file is in its own subfolder, because I print all the parts to pdf and keep them all with the song file.

If you do this, please make it possible to search within folders (directories) and subfolders to pick out the NWC filenames.