× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I hope this isn't too off topic - most Java developers on the iSeries have 
to deal will Qshell....

I needed a program to rename a bunch of files in a directory and all its 
subdirectories.  I could have written a Java program, but I, perhaps 
foolishly, thought this was something that could quickly be done in a 
Qshell script.  I am a novice at Unix and shell scripts, so I was hoping 
to learn something in the process.  I managed to cobb together something 
that does work -- it looks for files with embedded spaces and renames 
those files, replacing the space with a plus (+) sign.  The problem is, it 
is horribly slow!  I know scripts are interpreted, but it is quite a bit 
slower than I expected.

Perhaps a qshell guru out there can tell me the "correct" way to get the 
job done...

############
for i in *
do
 if test -d "$i"  #if file is directory...
 then
   cd "$i"        #go to directory
   $0 "$@"        #run the script again
   cd ..
 else             #otherwise this is a file
   newname=$(echo $i|sed '/ /s//+/g')
   if test "${i}" != "${newname}"
   then
     echo Current Name: ${i}
     echo New Name: ${newname}
     mv "${i}" "${newname}"
   fi
 fi
done
###############

===
Marshall Dunbar
DPS, Inc.
marshall@xxxxxxxxxxx
(317)574-4300 (800)654-4689
====

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.