Computing.Net > Forums > Unix > Help - File Name Manipulation

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help - File Name Manipulation

Reply to Message Icon

Name: af_25
Date: September 6, 2004 at 11:49:28 Pacific
OS: windows/unix
CPU/Ram: Intel P IV / Sun Sparc
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: anupam
Date: September 7, 2004 at 01:35:58 Pacific
Reply:

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


0

Response Number 2
Name: af_25
Date: September 7, 2004 at 08:58:06 Pacific
Reply:

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}.txt

I need to rename each version of the file and have them imported into a new version control tool.

Example :

abc{1}.txt --------> abc.txt


0

Response Number 3
Name: nails
Date: September 7, 2004 at 10:31:24 Pacific
Reply:

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")
done

Then move your filename to the new object.

Regards,

Nails



0

Response Number 4
Name: anupam
Date: September 7, 2004 at 22:18:51 Pacific
Reply:

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?


0

Response Number 5
Name: af_25
Date: September 8, 2004 at 11:43:31 Pacific
Reply:

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 on

As 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 file

rename abc{2}.txt ------> abc.txt
import the file

rename abc{3}.txt -------> abc.txt
import the file

so on


0

Related Posts

See More



Response Number 6
Name: anupam
Date: September 8, 2004 at 21:40:26 Pacific
Reply:

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.
done

you 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... :)


0

Response Number 7
Name: af_25
Date: September 9, 2004 at 16:39:07 Pacific
Reply:

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

-Anita-


0

Response Number 8
Name: anupam
Date: September 10, 2004 at 22:00:03 Pacific
Reply:

you are welcome.u should thank Nails also..he gave the script.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Help - File Name Manipulation

Extracting File names www.computing.net/answers/unix/extracting-file-names/4597.html

flexibility in file naming schemes?? www.computing.net/answers/unix/flexibility-in-file-naming-schemes/570.html

Read File name and pass to SQLoader www.computing.net/answers/unix/read-file-name-and-pass-to-sqloader/5543.html