Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

God I hate Windows

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Other OS
View previous topic :: View next topic  
Author Message
GMorgan
LXF regular


Joined: Thu Jan 12, 2006 6:58 pm
Posts: 684
Location: South Wales, UK

PostPosted: Thu Sep 14, 2006 11:11 am    Post subject: God I hate Windows Reply with quote

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.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Sep 14, 2006 11:48 am    Post subject: RE: God I hate Windows Reply with quote

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


To concatenate files from a DOS prompt in Windows, use
Code:
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 Smile
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
GMorgan
LXF regular


Joined: Thu Jan 12, 2006 6:58 pm
Posts: 684
Location: South Wales, UK

PostPosted: Thu Sep 14, 2006 8:34 pm    Post subject: RE: God I hate Windows Reply with quote

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.
Back to top
View user's profile Send private message
Rhakios
Moderator


Joined: Thu Apr 07, 2005 12:18 am
Posts: 7627
Location: Midlands, UK

PostPosted: Thu Sep 14, 2006 9:07 pm    Post subject: RE: God I hate Windows Reply with quote

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
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Sep 14, 2006 9:21 pm    Post subject: Re: RE: God I hate Windows Reply with quote

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:
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)
Back to top
View user's profile Send private message
GMorgan
LXF regular


Joined: Thu Jan 12, 2006 6:58 pm
Posts: 684
Location: South Wales, UK

PostPosted: Thu Sep 14, 2006 9:35 pm    Post subject: Re: RE: God I hate Windows Reply with quote

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:
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.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8452
Location: Warrington, UK

PostPosted: Thu Sep 14, 2006 10:01 pm    Post subject: RE: Re: RE: God I hate Windows Reply with quote

The shell expands the pattern before executing the command, so you end up with
Code:
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:
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)
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Other OS All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast