Operating System - HP-UX
1833451 Members
3120 Online
110052 Solutions
New Discussion

changing large number of file names

 
SOLVED
Go to solution
Jamie Chui
Occasional Advisor

changing large number of file names

Hi, somebody had sent me a gz file with lots of subdirectories. After I unzip them, I found that, for whatever reason, the one hundred plus files with different file names all had a ";1" attached to them, such as "LOGPROC;1" and "BITS.TXT;1". I wanted to globally remove all the ";1" for all the file names, including the ones inside subdirectories. Is there a way to do that? I don't want to have to change the file names individually...Thanks in advance!
10 REPLIES 10
Sundar_7
Honored Contributor
Solution

Re: changing large number of file names

Looks like something to do with M$ :-)

# cd /dir
# find . | while read FILE
do
NEWNAME=$(echo $FILE | sed 's/\;1//')
mv $FILE $NEWNAME
done


Learn What to do ,How to do and more importantly When to do ?
Dave Olker
Neighborhood Moderator

Re: changing large number of file names

I came up with something similar -

for FILE in $(ls -1 *";1")
do
NEWFILE=$(echo $FILE | awk -F";" '{print $1}')
mv $FILE $NEWFILE
done


Dave


I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Michael Schulte zur Sur
Honored Contributor

Re: changing large number of file names

Hi,

another try:

for F1 in *\;1
do
F2=`expr "${F1}" : "\(.*\);1"`
mv ${F1} ${F2}
done

greetings,

Michael

Hein van den Heuvel
Honored Contributor

Re: changing large number of file names

Sundar>> Looks like something to do with M$ :-)
Or... VMS maybe.

Jamie>> for whatever reason, the one hundred plus files with different file names all had a ";1" attached to them

Just in case you are curious about this, or just for you amuzement...

The filesystem ('files-11') for the HP OpenVMS Operating system (nee Digital's VAX/VMS) has a concept of file VERSIONS.

They are identified in a trailing ;
By default programs open the 'latests' version, for example test.txt;4, and editors would create new versions in this example test.txt;5. You can always address old versions directly, by absolute or relative number.
Directory records for VMS consist of a filename + an arrays of version-number + file-id ('i-node') pairs.
The "Purge" operation would delete all but the latests versions.

more than you cared to know huh?

Hein.
Bill Hassell
Honored Contributor

Re: changing large number of file names

Another source for ;1 version numbers on HP-UX is the standard CDROM subsystem. A simple mount for ISO-9660 or RockRidge CDs will show the ;1 version. All data CDs have UPPERCASE 8.3 file and directory names with the ;1 appended. It's part of the CDROM standard. HP-UX without patches will always show this directory.


Bill Hassell, sysadmin
Jose Mosquera
Honored Contributor

Re: changing large number of file names

Hi,

Without place to doubts, these files come from a Digital VAX/VMS source, the version controls and the names in capitals they are indicative unmistakable.

Pls try this:
#cd /
#find . -type f -name "*;1"|while read NAME
do
NEWNAME=`echo $NAME|awk -F";" '{print $1}'`
mv $NAME $NEWNAME
done


Rgds.
Muthukumar_5
Honored Contributor

Re: changing large number of file names

We can collect those files as,

find -name "*;1" -exec ll -a {}; -exec rm -i {}; -exec ll {} \;

It will ask you the permission to delete with the y/n. If you want to delete it with out any input then

find -name "*;1" -exec ll -a {}; -exec rm {}; -exec ll {} \;

If you want to rename it normally then,
find -name "*;1" -exec ls -a {} \; | awk -F ";" '{ print "mv \""$0"\" "$1 }'
Easy to suggest when don't know about the problem!
Jamie Chui
Occasional Advisor

Re: changing large number of file names

Thanks everyone for your quick response. I ran the script you taught me and it worked beautifully. Also thanks for info provided by Hein and Bill. Indeed it was an HP CD that I've mounted. I just found out that my HP-UX system needs the following patches:
PHCO_25841 s700_800 11.11 Add Rock Ridge extension to mount_cdfs(1M)
PHKL_26269 s700_800 11.11 Rock Ridge extension for ISO-9660
PHKL_28025 s700_800 11.11 Rock Ridge extension for ISO-9660
Jamie Chui
Occasional Advisor

Re: changing large number of file names

Regarding mounting the ISO-9660 or rockridge format CD, I just found out that using 'mount -F cdfs -o cdcase ......' would have avoided the problem. The cd was mounted with the correct file names and cases.
Bill Hassell
Honored Contributor

Re: changing large number of file names

Actually, the option -ocdcase is only a kludge. What it does is to still use the basic ISO 9660 directory or 8.3 names and ;1 version numbers. It then does a simple UPPER to lower translation and strips the version numbers. For some CDs, that is enough but it does not access the RockRidge directory, so long filenames will appear in a DOS-like format (longfilename.txt will be longfi~1.txt). So you'll still have to translate some directories and filenames. And for automated installs where the supplier/manufacturer is not aware of these HP-UX peculiarities, the install will fail to locate some files and directories.

The only workaround for 10.20 is to use the PFS toolset which does indeed access the RockRidge directory on the CD, but requires NFS and can be a bit unstable for use in a production system. For 11.xx, get the appropriate patches (always 3) and use -orr. Future release will probably default to -orr behavior (like most other Unices).


Bill Hassell, sysadmin