How to write rename script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write rename script?
# 1  
Old 08-26-2013
How to write rename script?

I have files fd01.calc,fd02.calc,fd03.calc..I want to rename in fd01.picks,fd02.picks,fd03.picks

How to do this?
# 2  
Old 08-26-2013
If you have less number of files:
Code:
for INDEX in 1 2 3
do
 mv fd0${INDEX}.calc fd0${INDEX}.picks
done

If you have these files in a directory and to rename all the files in the directory:
Code:
DIR=/your/directory
for FILENAME in $(ls $DIR)
do
 echo mv $FILENAME ${FILENAME%.*}.picks
done

Check the output and if it is okay then remove the red echo.
# 3  
Old 08-26-2013
Code:
ls *.calc | sed 's/\.calc$//' | xargs -i mv {}.calc {}.picks

# 4  
Old 08-26-2013
If your OS supports the rename command you can use this:

rename 's/calc/picks/' *.calc
# 5  
Old 08-26-2013
Try
Code:
for i in fd0{1..3}.calc; do echo mv $i ${i%.*}.picks; done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with file rename script

Hello, I'm new in this shell scripting subject, I´m looking forward for someone to give me a hint or advice as to how to tackle my requirement, which is as follows: We have a Linux process that runs periodically every day, this process dumps a text file with always the same name overwriting... (2 Replies)
Discussion started by: netosv
2 Replies

2. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

3. Shell Programming and Scripting

Script to rename files

I have the following directories in my home directory, my scripts dbmig es ms_done my-home I want my output to look like the following MyScripts DbmigEs MsDone MyHome Basically, I want to get rid of spaces,special characters and convert the first letter of each word to uppercase and... (1 Reply)
Discussion started by: ramky79
1 Replies

4. Shell Programming and Scripting

write shell script to rename file

hi, I need some help in writing shell script in a bourne shell.I am trying to rename the file.. eg. find /root/data -type f -name "text*) | while read FILES do newfile=${FILES/type_2.0_20101208_34.xml / tmp.xml} mv "$FILES" "$newfile" done above written script is working...If the... (7 Replies)
Discussion started by: shubhig15
7 Replies

5. Shell Programming and Scripting

Script Rename files

Hello, I have this problem. In a directory I have 4 csv files with this format: PHOENIX_KM_INTERAZIONI_YYYYMMDD.csv PHOENIX_KM_TRIPLETTE_YYYYMMDD.csv NEWCAB_KM_INTERAZIONI_YYYYMMDD.csv NEWCAB_KM_INTERAZIONI_YYYY_MM_DD.csv YYYYMMDD: format CURRENT date I wont rename all files in... (4 Replies)
Discussion started by: manichino74
4 Replies

6. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

7. UNIX for Dummies Questions & Answers

Script to Rename Files

I wrote a simple script that converts my windows text files to unix, so that I can compare them to different unix files purposes of my project. win2unix file1.txt file1Win.txt win2unix file2.txt file2Win.txt etc Is there a way to simplify this to: <while .txt in... (5 Replies)
Discussion started by: idano530
5 Replies

8. Shell Programming and Scripting

Rename /Script

Hi Guys, Here I have a simple rename script ... works perfectly fine. When files are on local machine ... But it will not work with the files on the server ... Server is mounted Path to the file is correct Permissions 777 I tried couple things .. and no luck that's why I'm here :) ... (2 Replies)
Discussion started by: NDxiak
2 Replies

9. Shell Programming and Scripting

Script to rename files

Let me preface this by stating I have absolutely no idea what I'm doing in this arena, but I'm in need of a little help here. I need to take filenames like this: amwed_0402c-slug~1-cp.jpg And reduce them to slug~1.jpg That is, I need to remove the first 12 and last 3 characters. The... (3 Replies)
Discussion started by: cpreovol
3 Replies

10. OS X (Apple)

Rename Files with a script ?

Hi All !!! Is there any solution to get rid of / " * in old files names WITH A SCRIPT (About 100 Gb of old files) I know it can be done i just dont know how ! Hope that some one can help Best R. Yovel (1 Reply)
Discussion started by: yoveln
1 Replies
Login or Register to Ask a Question