windows files to linux?

Ralph W. Reid rreid at sunset.net
Sun May 27 10:59:36 EDT 2007


My choice would be to replace the spaces with underline characters.
However, you indicated that you wanted space characters to be replaced
with ' _ ' strings--to each his own, I guess.  This little script
should do what you want (I hope).  Use at your own risk.

#!/bin/bash
#win2lin.sh
#converts Windblows file names to Linux file names
#Spaces in file names are translated to ' _ '
#upper case letters in file names are converted to lower case
#This script only performs conversions in the current directory--no
#directory tree traversal is provided.
#Use this script at your own risk.

function win2lin_func {
for i in *
do
  newname=`echo $i | tr [A-Z] [a-z] | sed "s/ / _ /g"`
  if [ "$newname" != "$i" ]; then
    echo Renaming \"$i\" to \"$newname\"
    mv -i "$i" "$newname"
  fi
done
}

#mainline code
#check for a single command line parameter

if [ "$#" != "1" ]; then
  echo Usage $0:
  echo $0 param/
  echo where param is the directory where files are to be renamed
  echo "(be sure to include the trailing /)."
  exit 1
fi

#process the file names
win2lin_func

#end of win2lin script

HTH, and have a _great_ day!

On Sat, May 26, 2007 at 10:30:34AM -0600, TheCreator wrote:
> Hello list,
> I've got a ton of files that have half capital letters, etc etc.
> I was wondering if there was a program that would go through and make my file names lowercase, (only on a selected folder), and put an _ between the spaces.
> Thanks,
> ~~TheCreator~~

-- 
Ralph.  N6BNO.  Wisdom comes from central processing, not from I/O.
rreid at sunset.net  http://personalweb.sunset.net/~rreid
...passing through The City of Internet at the speed of light...
_PI = 4 * ARCTAN (1)




More information about the Speakup mailing list