God I hate Windows

Help and discussion about non-Linux operating systems

Moderators: ChrisThornett, LXF moderators

God I hate Windows

Postby GMorgan » Thu Sep 14, 2006 10:11 am

My parents bought one of those (Linux based) Hauppauge MediaMVP's. Now it works in terms of how it was designed to work but I'm trying to get it to work as it should work using playlists. Of course this device only works in Windows despite being Linux based.

The tool I've given them for ripping their music creates an album playlist which takes the form b-%artist%-%album%.m3u and places them all in a common directory. Now I wanted to create a script that writes every entry from these album playlists into an uber all songs playlist called a-allsongs.m3u.

Now in Linux I'd just do this as a script
#rm -f a-allsongs.m3u
#cat b-*.m3u >> a-allsongs.m3u

In Windows I
#open each playlist in notepad and drag each list across to the common file

[sarcasm]See how easy Windows is. I managed to do it in one line there while that dirty commie OS takes 2 lines.[/sarcasm]

Any ideas how I can achieve this one click elusiveness in Windows. I'd prefer not to install cygwin on my parents machine.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: God I hate Windows

Postby nelz » Thu Sep 14, 2006 10:48 am

You can do it in one line with Linux with
Code: Select all
cat b-*.m3u >a-allsongs.m3u


To concatenate files from a DOS prompt in Windows, use
Code: Select all
copy \B \V src1 src2... dest


Pattern matching may or may not work. Even if it doesn't, you can still do the job in a single line, albeit a rather long one :)
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8521
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

RE: God I hate Windows

Postby GMorgan » Thu Sep 14, 2006 7:34 pm

Doesn't the first line wipe the destination document after each pass. I might be wrong though since I've never tried it in this context.

Problem with the second is the source documents will vary. As they add more albums I'm hoping to give them a simple script to update it for them, if they have to enter the names manually then it isn't simple. I'll try it with the pattern matching and see what falls out.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: God I hate Windows

Postby Rhakios » Thu Sep 14, 2006 8:07 pm

I think nelz's point is that a single > will replace the document's contents, thus making the rm -f redundant. The double >> is usually used to append to an existing file, though it will create a new one of course.
Bye, Rhakios
User avatar
Rhakios
Moderator
 
Posts: 7634
Joined: Wed Apr 06, 2005 11:18 pm
Location: Midlands, UK

Re: RE: God I hate Windows

Postby nelz » Thu Sep 14, 2006 8:21 pm

GMorgan wrote:Doesn't the first line wipe the destination document after each pass.


No, because you are recording the output from a single command. cat conCATenates the contents of the various files into a single stream, so there is no second output stream to overwrite the first. This is different from

Code: Select all
for i in b-*.m3u; do cat $i >all.m3u; done

which would overwrite all previous passes with the last.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8521
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Re: RE: God I hate Windows

Postby GMorgan » Thu Sep 14, 2006 8:35 pm

nelz wrote:
GMorgan wrote:Doesn't the first line wipe the destination document after each pass.


No, because you are recording the output from a single command. cat conCATenates the contents of the various files into a single stream, so there is no second output stream to overwrite the first. This is different from

Code: Select all
for i in b-*.m3u; do cat $i >all.m3u; done

which would overwrite all previous passes with the last.


Cheers for the explaination. I thought it would do something like

cat b-1.m3u > all.m3u
cat b-2.m3u > all.m3u
...

If it just adds all the files together then there is no problem.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: Re: RE: God I hate Windows

Postby nelz » Thu Sep 14, 2006 9:01 pm

The shell expands the pattern before executing the command, so you end up with
Code: Select all
cat b-1.m3u b-2.m3u ...


The output from this is then redirected to the file.

Incidentally, if you're worried about accidentally deleting the contents of a file by using > when you meant >>, put

Code: Select all
set -o noclobber


in /etc/profile, ~/.bashrc or anywhere where it will be run when you start a shell. It prevents > writing to an existing file. When you really mean to do that, you use >| instead. It's saved me trashing the likes of /etc/fstab on more than one occasion.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8521
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK


Return to Other OS

Who is online

Users browsing this forum: No registered users and 0 guests