how to rename all the files with one command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to rename all the files with one command?
# 1  
Old 07-03-2008
how to rename all the files with one command?

How do i rename all the files using a script ?
My server create log files and save them with numbering behind the name. for e.g. daily_20080101.log.0001 and so on ... How do a script and crontab it to remove all the numbering? Please help thanks.
# 2  
Old 07-03-2008
Code:
for f in daily*
do
    echo mv $f ${f%.[0-9]*}
done

Take out the echo when you have finished testing it...

Be careful though because daily_20080101.log.0001 will be overwritten by daily_20080101.log.0002 if it is also present?
# 3  
Old 07-03-2008
omg, it works! thanks Annihilannic ....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

2. UNIX for Dummies Questions & Answers

FTP rename command help

I have to ftp and rename the file with #finished# extension after successfully transfer. In some environments the command rename ABCD.dat ABCD.#finished# is working fine, but some environments its not working, I have to use escape character something like : rename ABCD.dat ABCD.\#finished\# Why is... (3 Replies)
Discussion started by: srikanth38
3 Replies

3. UNIX for Beginners Questions & Answers

Move and Rename in One Command

Hey all, I really need help with some homework I'm having on UNIX. This probably sounds stupid, but I'm being asked to move a file to a specific directory and rename it a specified name in one command. I know how to do it in more than one command, I just can't seem to figure it out using only one... (1 Reply)
Discussion started by: ayylmao12
1 Replies

4. Shell Programming and Scripting

Script to unzip files and Rename the Output-files

Hi all, I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
Discussion started by: pmkenya
2 Replies

5. Shell Programming and Scripting

ksh command to rename all files with no extension

hi! i want to rename all files with no extension with the extension DAT. with this command ls |grep -v "\\." i can list files but i dont know how i am going to rename them.. so i tried FILE_LIST=ls |grep -v "\\." for TEST_FILE in ${FILE_LIST} do mv $TEST_FILE... (2 Replies)
Discussion started by: kouppoua
2 Replies

6. Shell Programming and Scripting

Running rename command on large files and make it faster

Hi All, I have some 80,000 files in a directory which I need to rename. Below is the command which I am currently running and it seems, it is taking fore ever to run this command. This command seems too slow. Is there any way to speed up the command. I have have GNU Parallel installed on my... (6 Replies)
Discussion started by: shoaibjameel123
6 Replies

7. UNIX for Dummies Questions & Answers

mv command: mv vs rename operation

Hi all, I wish to know about a simple concept of mv command in UNIX. Is moving a file to a different directory takes longer than renaming it in the same direcotry using the mv command? The scenerio is that I have to transfer a file from one directory to a location which is regularly scanned... (3 Replies)
Discussion started by: sweety123
3 Replies

8. Shell Programming and Scripting

rename files Ax based on strings found in files Bx

Hi, I'm not very experienced in shell scripting and that's probably why I came across the following problem: I do have several hundred pairs of text files (PF00x.spl and PF00x.shd) where the first file (PF00x.spl) needs to be renamed according a string that is included in the second file... (12 Replies)
Discussion started by: inCH
12 Replies

9. Shell Programming and Scripting

mv command to rename multiple files that retain some portion of the original file nam

Well the title is not too good, so I will explain. I need to move (rename) files using a simple AIX script. ???file1.txt ???file2.txt ???file1a.txt ???file2a.txt to be: ???renamedfile1'date'.txt ???renamedfile2'date'.txt ???renamedfile1a'date'.txt ???renamedfile2a'date'.txt ... (4 Replies)
Discussion started by: grimace15
4 Replies

10. Shell Programming and Scripting

how to rename multiple files with a single command

Hi I have following list of files at a path: 01.AR.asset 01.AR.index 01.AR.asset.vf 01.AR.asset.xv I want to rename all these files as follows: 73.AR.asset.Z 73.AR.index.Z 73.AR.asset.vf.Z 73.AR.asset.xv.Z Can any body give me a single command to acheive the above results. ... (5 Replies)
Discussion started by: tayyabq8
5 Replies
Login or Register to Ask a Question