NoteWorthySoftware.com
My Noteworthy Software Community  
2010-09-02 10:29 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Licensed NWC2 users can upgrade their community membership [more]
 
   Home   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Making a catalog of your NWC files  (Read 16115 times)
NoteWorthy Online
Admin

Offline Offline

Posts: 3160


« on: 2003-11-21 11:43 am »

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:

Logged
Marsu
Virtuoso

Offline Offline

Posts: 365


« Reply #1 on: 2003-12-22 03:46 pm »

...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!)
Logged
Ertuğrul İnanç
Virtuoso

Offline Offline

Posts: 504

Absent lurker


« Reply #2 on: 2004-10-28 04:29 pm »

-
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.
_
Logged

Peter Struys
NWC2 User

Offline Offline

Posts: 5


« Reply #3 on: 2007-06-14 09:55 am »

Is the NWC Info program also working with NWC 2 files?
Logged
NoteWorthy Online
Admin

Offline Offline

Posts: 3160


« Reply #4 on: 2007-06-14 10:17 am »

Refer to:

NoteWorthy Composer 2 File Information Extraction Tool
http://ntworthy.com/nwc2/nwcinfo.htm
Logged
Peter Struys
NWC2 User

Offline Offline

Posts: 5


« Reply #5 on: 2007-06-14 10:26 am »

Perfect.

Many thanks!
Logged
Rick G.
Virtuoso

Offline Offline

Posts: 2360

Mostly piano; some flute arranging.


« Reply #6 on: 2008-11-17 03:53 pm »

This works in WinXP and Win98:

1. Put nwcinfo.exe somewhere in your path. I put my copy in: c:\windows\system32
2. Save the following line as nwcinfo.bat
Quote
%ComSpec% /c dir /s/b *.nwc | NWCINFO /list > %temp%\nwcinfo.txt
3. Create a shortcut to nwcinfo.bat
4. Make the shortcut's Start in: the location of your Song files.

When the shortcut is run, it will produce the list you want in your temporary folder.
If it finds any *.nwctxt files, useless error messages are displayed.
Logged

Registered user since 1996
Rick G.
Virtuoso

Offline Offline

Posts: 2360

Mostly piano; some flute arranging.


« Reply #7 on: 2008-11-19 04:12 am »

Why does executing that command through the shell ("CMD") should be different from executing it directly?
Because dir is an internal parameter fed to the shell. There is no program called dir.exe (or dir.com).

All the files using ANSI chars above the ASCII standard in their names were simply "not found".
This seems to be a limitation of NWCINFO when used with the /list switch. The filenames are limited to 7bit ASCII.
If I quote the filename as a parameter to NWCINFO, it processes it, but if I put the same filename in a text file and pipe it into NWCINFO /list, it sends: File not found to STDERR

You can put the 8.3 path in:
Quote from: temp.txt
C:\My Documents\NW Music\_ng\Upload\rg_liebeslieder nø5.nwc
C:\MYDOCU~1\NWMUSI~1\_NG\UPLOAD\RG_LIE~1.NWC
Running: NWCINFO /list < temp.txt
will err on the first line, but correctly report the second line.

All this could be solved with a dozen lines of JScript, but it would take a few hours to debug.
Logged

Registered user since 1996
Rick G.
Virtuoso

Offline Offline

Posts: 2360

Mostly piano; some flute arranging.


« Reply #8 on: 2008-11-19 03:00 pm »

You are correct. %ComSpec% /c is unnecessary here. My original attempt was avoid the batch file and do it all from the shortcut. I couldn't get that to work. The %ComSpec% reference was a leftover from that attempt.

Since you started this in Tips & Tricks, you could rewrite all this as one correct tip and remove all my replies. I won't take offense.

Well, probably this could be solved more easily and in a much cleaner way trough a few lines... in NWCINFO.
Right? ;-)
Perhaps. Before long file names, the OS would simply replace the first character in the 8.3 filename with a character with the high bit set to indicate that it was deleted. This made it possible to open/restore deleted files. One way to avoid doing this inadvertently was to clear the high bit on any string requesting a file open.
Logged

Registered user since 1996
BobPetty
Member

Offline Offline

Posts: 24


« Reply #9 on: 2008-11-20 03:23 pm »

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
Logged
Flurmy
Virtuoso

Offline Offline

Posts: 302

Maurizio Spagni


« Reply #10 on: 2008-11-21 03:17 am »

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:
%ComSpec% /a /c dir /s /b *.nwc > foo
but the result is unchanged.

Using the command
Code:
%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...
Logged
NoteWorthy Online
Admin

Offline Offline

Posts: 3160


« Reply #11 on: 2008-11-24 04:12 pm »

Flurmy, you have it exactly correct. Another explanation can be seen here:

http://blogs.msdn.com/oldnewthing/archive/2005/03/08/389527.aspx

I could not find a good answer for you on this one given the current behavior of the command Window and the NWCInfo tool.
Logged
BobPetty
Member

Offline Offline

Posts: 24


« Reply #12 on: 2008-11-24 04:19 pm »

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)
Logged
David Palmquist
Virtuoso

Offline Offline

Posts: 2550

Registered since version 1.30


« Reply #13 on: 2008-11-25 03:24 am »

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.

Logged

Flurmy
Virtuoso

Offline Offline

Posts: 302

Maurizio Spagni


« Reply #14 on: 2008-11-25 03:55 am »

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:
@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:
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.
Logged
NoteWorthy Online
Admin

Offline Offline

Posts: 3160


« Reply #15 on: 2008-11-25 06:18 am »

We will consider a better method for making a *.nwc catalog.
Logged
David Palmquist
Virtuoso

Offline Offline

Posts: 2550

Registered since version 1.30


« Reply #16 on: 2008-11-25 08:57 pm »

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.   
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Page created in 0.077 seconds with 16 queries.

Copyright © 2010 Noteworthy Software, Inc.
All Rights Reserved