I was just playing with some old disk images of SCO Xenix to try to get it to boot in an emulator. It was quite frustrating that all of the disk images had spaces in the file names. A few files would have been ok, but I have multiple version of multiple releases for multiple CPU architectures.
I was just about to create a script to rename all the files to change the spaces to underscores. But, since I just woke up a few hours ago, and haven’t had any Caffiene yet, I figured I’d find a script already written.
The first one I found was this one which worked really well.
To use it, you just do a find and -exec the files found to the script. I named my script “dashem”.
$ ls -1
SCO Xenix 386 System V v2.3.4 (Disk B1).vfd
SCO Xenix 386 System V v2.3.4 (Disk N1).vfd
SCO Xenix 386 System V v2.3.4 (Disk N2).vfd
SCO Xenix 386 System V v2.3.4 (Disk X1).vfd
SCO Xenix 386 System V v2.3.4 (Disk X2).vfd
SCO Xenix 386 System V v2.3.4 (Disk X3).vfd
SCO Xenix 386 System V v2.3.4 (Disk X4).vfd$ find . -name “*.vfd” -exec ~/bin/dashem {} \;
$ ls -1
SCO_Xenix_386_System_V_v2.3.4_(Disk_B1).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_N1).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_N2).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_X1).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_X2).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_X3).vfd
SCO_Xenix_386_System_V_v2.3.4_(Disk_X4).vfd
Beautiful! Just be careful where you run this. Most UNIX filesystems don’t have many (any?) files with spaces. But, you may not want all of your files renamed. You may want to add a few arguments to find such as “-maxdepth”, etc.
Also, it’s generally a good idea, anytime you are going to use find and “-exec” the results, to run the find command without the exec and make sure it’s only finding the files you want to exec.
For example, my previous command without the exec:
$ find . -name “*.vfd”
./SCO Xenix 386 System V v2.3.4 (Disk B1).vfd
./SCO Xenix 386 System V v2.3.4 (Disk N1).vfd
./SCO Xenix 386 System V v2.3.4 (Disk N2).vfd
./SCO Xenix 386 System V v2.3.4 (Disk X1).vfd
./SCO Xenix 386 System V v2.3.4 (Disk X2).vfd
./SCO Xenix 386 System V v2.3.4 (Disk X3).vfd
./SCO Xenix 386 System V v2.3.4 (Disk X4).vfd
I always do the find first and add the “-exec” after I am sure I’m only going to work with the files I really wanted to. Find, without any search criteria will, by default, find every file recursively underneath the starting point.
![[del.icio.us]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/facebook.png)
![[Twitter]](http://www.theunixzone.com/wp-content/plugins/bookmarkify/twitter.png)