Well, the first statement (for e in *) gets all the files in the directory. We then take each one (stored in the $e var) and do a mv (move) from $e to $e. But the second $e we echo it out and pipe it into sed which does a search/replace on _ with nothing before using it. That way we end up essentially doing a

mv file_name filename

for each file to rename them without underscores. Not sure how it could be simplified.

CB

On 12/12/11 5:18 PM, Ray Foret Jr wrote:
Gee.  All that code just to do that?

I don't get it.


Sincerely,
The Constantly Barefooted Ray!!!

Now a very proud and happy Mac user!!!

Skype name:
barefootedray

Facebook:
facebook.com/ray.foretjr.1 <http://m.facebook.com/ray.foretjr.1?refid=0>



On Dec 12, 2011, at 4:03 PM, Chris Blouch wrote:

Ahh, so you need something like this:

for e in *; do mv "$e" "`echo $e | sed 's/[_]*//g'`"; done

which takes all the files in the current directory and removes the _ from their filename. So two_three-Four.mp3 becomes twothreefour.mp3

CB

On 12/12/11 2:52 PM, Eric Oyen wrote:
what I was attempting to do was remove the underscore from between filename elements. I have a huge number of mp3 files here.

I use terminal for some of this operation but I tend to lose track of where I am.

-eric

On Dec 12, 2011, at 8:55 AM, Chris Blouch wrote:

I guess I'm not clear what problem you are trying to solve. Are you trying to add .mp3 to a bunch of files? If that's the case you could just do this in terminal. Go to the folder with the mp3 files you want to add .mp3 to and do this:

for e in *; do mv "$e" "`echo $e | sed -e ''`.mp3"; done

You'll find all the files now have .mp3 appended to the end. Warning, this will also append .mp3 to folders so use with care. Probably ways to prevent that and do recursion.

CB

On 12/12/11 2:03 AM, Eric Oyen wrote:
well,
I was facing the daunting task of renaming massive numbers of files (specifically my mp3 library) and I hit upon an idea that I used to use in windows: using an archive program to store the media files in (no compression) and then append the proper extenuation after the file was made. the program in this case is tar (Tape Archiver). after I get done using tar to create the storage file, I erase the mp3's involved and then rename the file with the new .mp3 extenuation. VIOLA! playable mp3 file that even works in itunes!


sometimes the old tricks are still the best.

this little trick not only cuts down the number of files in my library, but it makes it easier to copy them to my various devices for playback.

-eric


--
You received this message because you are subscribed to the Google Groups "MacVisionaries" group. To post to this group, send email to [email protected] <mailto:[email protected]>. To unsubscribe from this group, send email to [email protected] <mailto:[email protected]>. For more options, visit this group at http://groups.google.com/group/macvisionaries?hl=en.


--
You received this message because you are subscribed to the Google Groups "MacVisionaries" group. To post to this group, send email to [email protected] <mailto:[email protected]>. To unsubscribe from this group, send email to [email protected] <mailto:[email protected]>. For more options, visit this group at http://groups.google.com/group/macvisionaries?hl=en.


--
You received this message because you are subscribed to the Google Groups "MacVisionaries" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/macvisionaries?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/macvisionaries?hl=en.

Reply via email to