473,511 Members | 10,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rename the files

23 New Member
Hi all,
I want to rename the files using substitution method, for ex
i have list of files of test_001.c,test_002.c,test_003.c etc
i need to modify the "test" to "test_src"

alpha$: ls -al | sed -e 's/test/test_src/g'

this is not working,can anybody suggest me the bug in the command pls.

Thxs,
manik
Jul 23 '07 #1
3 2412
sarang
5 New Member
you can use 'mv' command to remane files
ex, 'mv test test_src'
Jul 23 '07 #2
radoulov
34 New Member
Hi all,
I want to rename the files using substitution method, for ex
i have list of files of test_001.c,test_002.c,test_003.c etc
i need to modify the "test" to "test_src"
[...]
If you have rename (on Linux, for example):
Expand|Select|Wrap|Line Numbers
  1. rename test test_src test*.c
With zsh:
Expand|Select|Wrap|Line Numbers
  1. autoload -U zmv
  2. zmv 'test_(*)' 'test_src_$1'
With bash/ksh93(not ksh88!):
Expand|Select|Wrap|Line Numbers
  1. $ for i in test*.c;do mv "$i" "${i/test/test_src}";done
Otherwise:
Expand|Select|Wrap|Line Numbers
  1. for i in test*.c;do mv "$i" test_src"${i#????}";done
Jul 23 '07 #3
manimarank
23 New Member
If you have rename (on Linux, for example):
Expand|Select|Wrap|Line Numbers
  1. rename test test_src test*.c
With zsh:
Expand|Select|Wrap|Line Numbers
  1. autoload -U zmv
  2. zmv 'test_(*)' 'test_src_$1'
With bash/ksh93(not ksh88!):
Expand|Select|Wrap|Line Numbers
  1. $ for i in test*.c;do mv "$i" "${i/test/test_src}";done
Otherwise:
Expand|Select|Wrap|Line Numbers
  1. for i in test*.c;do mv "$i" test_src"${i#????}";done
Thanks for your support!!!
Jul 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4618
by: fanbanlo | last post by:
C:\MP3\001.txt -> 0.txt C:\MP3\01. ??? - ????(???).mp3 -> 1.mp3 Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in...
16
2956
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3...
3
1789
by: Erik Foreman | last post by:
I am using a folderbrowserdialog object to prowse to a folder then once in that folder I am going to have my program rename all of the files in that folder. I know the rename funchtion but I am not...
5
4442
by: Rothariger | last post by:
Hello.... i want to know if its posible to rename multiple files like windows does.. example: file zzzzzzz.doc file asdasd.doc file esfsefse.doc
6
2514
by: shuaishuaiyes | last post by:
Hello everyone... I'm a Chinese student and my English is very poor...So excuse me if I make grammar mistake. I want to ask some questions about "rename". I'm a beginner, so my C ..... :) I...
1
1968
by: jonathan184 | last post by:
trying to rename filenames and extensions then add a header in line1 of each file if the header existed in line 1 to go to the next file. but i am getting error explciti errors Here is my...
2
3613
by: =?iso-8859-1?b?cultaQ==?= | last post by:
Hi, I would like to rename files (jpg's ones) using a text file containing the new names... Below is the code that doesn't work : ***** #!/usr/bin/python #-*- coding: utf-8 -*- from os...
1
1608
by: lukas | last post by:
hello, i recently had the job of having to rename about 200 files. The source for the renaming was a bunch of names in a file. I know next to nothing when it comes to bash scripting (which would...
2
1714
by: newyorker213 | last post by:
Hello, We have files ( named in the following format ) in one of our folders: MV0001.XLS MV0002.XLS and so on WV0001.XLS WV0002.XLS
1
5688
by: achotto | last post by:
hi, i try to upload a multiple image files. after that i will rename the files name. the problem is when i upload a 2 or more same files name exp-goal.jpg, it will return "files already exist". ok...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.