Solved

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

Posted on 2000-04-27
1
1,609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 21

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

615 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