Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I working on data migration with respect to version control files. I have encountered an issue where the extracted file version are as filename{1).*, filename{2}.* .....
Any help on manipulating filename{1).* to filename.* would be appreciated.Thanks
Anita

can u elborate and give 1-2 examples of filenames extracted and the filenames they have to be converted to.

Version control files extracted from documentum/eroom have the following file naming convention :
Example
abc{1}.txt
abc{2}.txt
abc{3}.txt
abc{4}.txtI need to rename each version of the file and have them imported into a new version control tool.
Example :
abc{1}.txt --------> abc.txt

Hi:
One way is to use a filename with the curly braces removed. Do this with the sed command:
#!/bin/ksh
f=$(ls *{*)
for i in $f
do
mv $i $(echo "$i"|sed "s/[{}]//g")
doneThen move your filename to the new object.
Regards,
Nails

hi..
u want to rename abc{1}.txt to abc1.txt or abc.txt?if all your version control files are in the same directory and u want to rename all abc{*}.txt(* being for 1,2,3....) to abc.txt,then wouldn't all the version control files : abc{1}.txt,abc{2}.txt etc get overwritten by only one file i.e. abc.txt?

Thank you'll for all the response, and sorry not been clear about my request. The version control files within the directory appear as :
abc{1}.txt
abc{2}.txt
abc{3}.txt
.
.
so onAs part of my migration effort, I would rename the version one with just the file name have it imported and then rename version 2 and so on.
Migration procedure :
rename abc{1}.txt -----> abc.txt
import the filerename abc{2}.txt ------> abc.txt
import the filerename abc{3}.txt -------> abc.txt
import the fileso on

if you want to import one file at a time,then i think its as good as renaming it manually and then proceeding.but if u want to rename and also import all the version control files in a batch then i think the script which Nails suggested would work fine with some minor changes including changes to remove numbers also :
#!/bin/ksh
f=`ls *{*`
for i in $f
do
mv $i `echo "$i"|sed "s/[0-9{}]//g"`
#your code for import goes after this.
doneyou can use proper command for ls above so that you select the proper files to be affected by the script.note the quotation marks as they are important.i suggest that you first test run this script in a different directory with some test files and then see if it works alright for you.best of luck.
tell us if it worked for you... :)

Thank you Anupam, the script works perfectly fine. Its been off great help with my migration effort, I do appreciate the timely help.
-Anita-

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |