New to Mac from Windows...Need some insight

R

Ragggit

Guest
I have about 45,000 mp3's all with the mac naming convention.
I have a windows file server but im sure all of you know that you
just cant run the files through the network and windows eat them up
like candy. I've found a script at http://www.computing.net/unix/wwwboard/forum/6079.html that I would like to try.
What I need to do is get rid of "ALL" the special characters that are in my
filename.mp3 and replace them with something or just have them removed so that the filename convention will work on a windows machine. I've not one clue if that script that is on that page will work but hopefully it will.
My other question is this, how do i make that script work in a certain directory? Do i have to create a file and chmod it etc etc, if that is the case could someone please give me step by step on how to manage this task...

Thanks

Raggit
 
Joined
Aug 12, 2004
Messages
251
Reaction score
2
Points
18
Location
London, UK
I had the same problem and found a little app called Renamer4mac which has a search and replace function. i searched for the invalid characters one by one and replaced with windows acceptable ones.

You can search by folder so it's not as labourious as it sounds.

Good Luck
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
This script (I just wrote) is a little safer that the one you linked to. The one referred does a move which effectively renames files. If you have an alias for that command that forces the move, you could overwrite one file with another, permanently losing the first.

It creates a directory and copies all of the files from the directory your in, into a lower level directory (folder) named tempdir.

The easiest way to get this into a proper Unix text file is at the Terminal window. Just copy the script, do a 'cat >myscriptname.csh' at the prompt, and paste the text in. The very first line should be '#!/bin/csh'.

Then change the permissions so you have execute priviledge. Type 'chmod u+x myscriptname.csh' at the prompt.

The first line may have to be altered depending on where Apple placed the csh shell. You can find out by typing 'whereis csh' at the Unix prompt.

To use the script set your directory location via the cd command, then type /theFullPath/myscriptname.csh or if you placed the script into the directory you where your changing the filenames, type ./myscriptname.csh

If you know the minus sign is a valid character for the file system your transfering to, then just add it after the period in the first part the sed command string.

This is a quicky hack. It does not traverse down the folders. I don't have time to figure that out right now, as I'm at work which I need to get back to.

\/\/\/\/ Beginning of script below this line to bottom of message.
#!/bin/csh

if ( ! -e tempdir ) then
mkdir tempdir
endif

foreach file ( `ls -1` )
if ($file != 'tempdir') then
cp $file `echo "$file" | sed -e 's/[^A-Za-z0-9_.]/_/g' -e 's/^/tempdir\//'`
endif
end
exit
 
OP
R

Ragggit

Guest
xstep said:
This script (I just wrote) is a little safer that the one you linked to. The one referred does a move which effectively renames files. If you have an alias for that command that forces the move, you could overwrite one file with another, permanently losing the first.

It creates a directory and copies all of the files from the directory your in, into a lower level directory (folder) named tempdir.

The easiest way to get this into a proper Unix text file is at the Terminal window. Just copy the script, do a 'cat >myscriptname.csh' at the prompt, and paste the text in. The very first line should be '#!/bin/csh'.

Then change the permissions so you have execute priviledge. Type 'chmod u+x myscriptname.csh' at the prompt.

The first line may have to be altered depending on where Apple placed the csh shell. You can find out by typing 'whereis csh' at the Unix prompt.

To use the script set your directory location via the cd command, then type /theFullPath/myscriptname.csh or if you placed the script into the directory you where your changing the filenames, type ./myscriptname.csh

If you know the minus sign is a valid character for the file system your transfering to, then just add it after the period in the first part the sed command string.

This is a quicky hack. It does not traverse down the folders. I don't have time to figure that out right now, as I'm at work which I need to get back to.

\/\/\/\/ Beginning of script below this line to bottom of message.
#!/bin/csh

if ( ! -e tempdir ) then
mkdir tempdir
endif

foreach file ( `ls -1` )
if ($file != 'tempdir') then
cp $file `echo "$file" | sed -e 's/[^A-Za-z0-9_.]/_/g' -e 's/^/tempdir\//'`
endif
end
exit

Thank you so much for the time you spent on this post. I know that everyones time is precious and I sincerely appreciate you taking time out of your day to assist me in this problem.

I'm concerned about one thing though, you said that the files would be moved into a tmp diectory well I haven't enough space for that as you can imagine 47,000 mp3s takes up some space. It would be extremely wonderful if this script were able to traverse directories since scrolling from folder to folder inside artist/album is WOW , cumbersome. Is there a quik fix to make it traverse directories if so how?

P.S- sorry for the delay in response time, work has kept me extremely busy
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
Your welcome.

Changing the 'cp' to 'mv' will do a rename instead of a move.

Since you won't want to deal with a new subdirectory structure, remove -e 's/^/tempdir\//'. Note you need the last back-quote in my original code.

There is no 'quick fix' for traversing the directories. I'll see if I can write some code to traverse the directories. I'm just curious how I'll do it in csh. I haven't had a need to do that before so it is an interesting challenge for possible future use. Yes, I have an idea.
 
Joined
Nov 16, 2004
Messages
407
Reaction score
10
Points
18
Location
London, UK
Your Mac's Specs
MacBook | 1.83ghz | 2gb ram
If you're on Tiger you can use Automator for this task.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top