| 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
|
Posted: Thu Sep 14, 2006 11:11 am Post subject: God I hate Windows |
|
|
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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7997 Location: Warrington, UK
|
Posted: Thu Sep 14, 2006 11:48 am Post subject: RE: God I hate Windows |
|
|
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  _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
GMorgan LXF regular
Joined: Thu Jan 12, 2006 6:58 pm Posts: 684 Location: South Wales, UK
|
Posted: Thu Sep 14, 2006 8:34 pm Post subject: RE: God I hate Windows |
|
|
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 |
|
 |
Rhakios Moderator

Joined: Thu Apr 07, 2005 12:18 am Posts: 7473 Location: Midlands, UK
|
Posted: Thu Sep 14, 2006 9:07 pm Post subject: RE: God I hate Windows |
|
|
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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7997 Location: Warrington, UK
|
Posted: Thu Sep 14, 2006 9:21 pm Post subject: Re: RE: God I hate Windows |
|
|
| 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. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
GMorgan LXF regular
Joined: Thu Jan 12, 2006 6:58 pm Posts: 684 Location: South Wales, UK
|
Posted: Thu Sep 14, 2006 9:35 pm Post subject: Re: RE: God I hate Windows |
|
|
| 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 |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 7997 Location: Warrington, UK
|
Posted: Thu Sep 14, 2006 10:01 pm Post subject: RE: Re: RE: God I hate Windows |
|
|
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
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. _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|