Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-04-27
1
Medium Priority
?
1,632 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 21

Accepted Solution

by:
tfewster earned 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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…
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…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

963 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