Solved

script to replace spaces in file names with dash or underscore.

Posted on 2000-04-27
1
1,574 Views
Last Modified: 2013-12-06
I'm using HP-UX. I have a whole directory of several files imported from NT with spaces in the file names.
I need a script to change the all the spaces in the file names to underscore.

example:

fig 3-23 11 of 14.tif  to  fig_3-23_11_of_14.tif

0
Comment
Question by:RobbManess
1 Comment
 
LVL 20

Accepted Solution

by:
tfewster earned 50 total points
ID: 2756381
Create a little shell script in the directory, e.g. "rs.sh", like so:

mv "$1" `echo $1 | tr " " "_"`

Execute this in the directory with:
find . -name "*.tif" -exec ./rs.sh {} \;



0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question