 |
 |
unix guru help
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Palo Alto, CA
Status:
Offline
|
|
I am looking for a quick way to do the following:
append ".mp3" to all the files in a specific folder that do not already end in ".mp3" (right now they are being read as text files.
Note that within the folder there are tons of nested subfolders...
Is there any easy way to do this?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2003
Location: Pittsburgh, Pennsylvania
Status:
Offline
|
|
Originally posted by barbarian:
I am looking for a quick way to do the following:
append ".mp3" to all the files in a specific folder that do not already end in ".mp3" (right now they are being read as text files.
Note that within the folder there are tons of nested subfolders...
Is there any easy way to do this?
I have three words for you
Perl
Regular Expressions
write a recursive function that goes through all the directories, and it checks if the file ends in .mp3, if not append it. I'm not the best at regular expressions, but about 10min of googling and 10min of coding and you should be set.
Nate
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
Here's a simple approach that works OK on my tests. (Standard warning: check it out on a sample directory first!) It just uses some of the inbuilt goodness of zsh. At a terminal prompt ( % ) enter:
Then enter
Code:
for file in **/*~*.mp3(.)
You should see a "for>" symbol. Enter
and you're done. "exit" will get you out of zsh and you're back where you started, but hopefully without the renaming problem any more.
Best of luck,
Paul (who knows all too well that this could be done with find and exec, and maybe xargs and blah blah blah: but what fun would that be?)
(Last edited by Paul McCann; Sep 23, 2003 at 02:42 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status:
Offline
|
|
You have an apple script that does that
look in /Library/Scripts/Finder Scripts
run the one called "Add to File Names.scpt"
cheers
|
|
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2001
Status:
Offline
|
|
Originally posted by barbarian:
I am looking for a quick way to do the following:
append ".mp3" to all the files in a specific folder that do not already end in ".mp3" (right now they are being read as text files.
Note that within the folder there are tons of nested subfolders...
Is there any easy way to do this?
IMHO the best way is to go to version tracker and download one of the many apps or contextual menus for the finder that does this for you.

|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jul 2002
Location: Leiden, Netherlands
Status:
Offline
|
|
Originally posted by Paul McCann:
mv "$file " "$file".mp3
will work a lot better with file that contains a space in their filename.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
Originally posted by Ludovic Hirlimann:
mv "$file" "$file".mp3
will work a lot better with file that contains a space in their filename.
Yes indeed: thanks for the correction. One day I'll remember that people really do use spaces in filenames.
Cheers,
Paul
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|