| OS X - Apps and Games Discussion of applications and games available for Mac OS X. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Jun 14, 2006
Posts: 140
![]() |
Not sure if this is the right forum, but can someone write me a script that will strip all 2nd spaces in a file name?
Example. If a file name is: Junk Mail.txt it will make it Junk Mail.txt (gets rid of the extra space. Everytime I transfer files to my linux box that have more than one consecutive space, it doesn't seem to open, transfer back, or anything. I'm not sure if there is an option in linux to fix this (running SuSe 10.1). But I would like to have a script to be able to do this to all files in a single directory. Thanks! |
| QUOTE Thanks | |
![]() Member Since: Jun 06, 2006
Posts: 1,153
![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook 2.0GHz White, 512MB RAM, 60GB HDD
|
There's no reason you can't have multiple consecutive spaces in filenames in linux. You just have to remember to put quotes round the filename or escape each space individually.
However, to do what you want, try this (it should work under Linux, and quite possibly under Mac OS X too, as long as you are using bash) Code:
for f in *
do
n=${f// */ /} # <-- note that this is f//{space}{space}*/{space}/
mv "$f" "$n"
done
Last edited by cazabam; 07-14-2006 at 08:05 AM. Reason: global search/replace |
| QUOTE Thanks | |
![]() Member Since: Jun 14, 2006
Posts: 140
![]() |
Last edited by unplugged; 07-14-2006 at 08:18 AM. |
| QUOTE Thanks | |
![]() Member Since: Jun 06, 2006
Posts: 1,153
![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook 2.0GHz White, 512MB RAM, 60GB HDD
|
|
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Script Wrapper?? | meskue | OS X - Development and Darwin | 1 | 06-24-2006 02:02 PM |
| Quick Apple Script Question | ezhangin | OS X - Development and Darwin | 6 | 12-14-2005 09:30 PM |
| MacAddict Backup Script | sevenhelmet | OS X - Development and Darwin | 7 | 09-18-2005 03:56 PM |
| Need some help on a unix script :-) | starrin | OS X - Operating System | 0 | 12-01-2004 08:55 PM |
| Ooops - dragged a script to the Finder!! | kjellquist | OS X - Operating System | 1 | 03-15-2004 06:46 PM |
All times are GMT -4. The time now is 05:05 AM.
Powered by vBulletin