Virchanza
12-04-2008, 11:31 AM
I'm thinking of coding a program but I dunno if it's been done before so I wanna ask here first before I waste my time.
Take a program like "find" that prints strings to the screen. Let's say you want to perform an operation on every string that it prints, and let's say that the operation is as follows:
rm X
(where X is the string that comes out of "find")
Well the idea is that I'd have a program called "many" that you use as follows:
find | many rm X
What it does is perform the operation "rm X" on every string that gets printed by "find".
I came up with this idea because I was moving all my stuff from my MSWindows partition across to my Linux partition (I'm abandoning MSWindows in favour of Linux). So anyway, my Windows folders had all sorts of stupid names like "My Videos", so I wanted a quick way of doing the following to every file and directory:
1) Replace uppercase characters with lowercase
2) Replace spaces with underscores
3) Remove "My " at the start
To do the filename conversion, I could have an extremely simple little command line program that takes an input such as "My Home Videos" and gives the output as "home_videos". Let's say this program is call "name_linifier".
It would be great to be able to use "name_linifier" as follows:
find | many mv X `name_linifier X`
Does such a program already exist? It would be so immensely useful that I get the idea it's been done before, but if it hasn't then I'll get coding it right away.
(By the way I realise I'll have a little problem parsing `name_linifier X` but it won't be a problem, I've already got a workaround in mind, I can just replace the apostrophe character with some other character of choice)
Take a program like "find" that prints strings to the screen. Let's say you want to perform an operation on every string that it prints, and let's say that the operation is as follows:
rm X
(where X is the string that comes out of "find")
Well the idea is that I'd have a program called "many" that you use as follows:
find | many rm X
What it does is perform the operation "rm X" on every string that gets printed by "find".
I came up with this idea because I was moving all my stuff from my MSWindows partition across to my Linux partition (I'm abandoning MSWindows in favour of Linux). So anyway, my Windows folders had all sorts of stupid names like "My Videos", so I wanted a quick way of doing the following to every file and directory:
1) Replace uppercase characters with lowercase
2) Replace spaces with underscores
3) Remove "My " at the start
To do the filename conversion, I could have an extremely simple little command line program that takes an input such as "My Home Videos" and gives the output as "home_videos". Let's say this program is call "name_linifier".
It would be great to be able to use "name_linifier" as follows:
find | many mv X `name_linifier X`
Does such a program already exist? It would be so immensely useful that I get the idea it's been done before, but if it hasn't then I'll get coding it right away.
(By the way I realise I'll have a little problem parsing `name_linifier X` but it won't be a problem, I've already got a workaround in mind, I can just replace the apostrophe character with some other character of choice)