473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

rename the files

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 2410
sarang
5
you can use 'mv' command to remane files
ex, 'mv test test_src'
Jul 23 '07 #2
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
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
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.