renaming 50k files, whats the best way?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting renaming 50k files, whats the best way?
# 1  
Old 01-12-2006
renaming 50k files, whats the best way?

Because I am not creative, I did this:
find . -type f -name '*.GIF'|cut -d'/' -f2|awk -F. '{print "mv "$1".GIF "$1".gif --reply=yes"}' > case.sh

Then ran the case.sh - I was wondering if you guys could come up with something more efficient? Or even limit CPU useage? It is killing my poor ext3 linux server.
# 2  
Old 01-12-2006
ls *.GIF | xargs -I {} basename {} .GIF | xargs -I {} mv {}.GIF {}.gif
# 3  
Old 01-13-2006
nice - yes this is much better, although I still had to use find (ls broke). Thanks!
# 4  
Old 01-13-2006
In ksh:

for i in *.GIF ; do echo mv $i ${i%.*}.gif ; done

Use the echo to preview what this will do. Make sure the output looks good. Then rerun the above command without that "echo" to actually do the moves.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

2. UNIX for Dummies Questions & Answers

Help with renaming the files.

Hi, I have 31 file as below.... dt_ref_med_merged_madt_h_19980101.nc .. .. dt_ref_med_merged_madt_h_19980131.nc I want to rename it like... dt_ref_med_merged_madt_h_1998_1.nc .. .. dt_ref_med_merged_madt_h_1998_31.nc How can I do it ? any suggestions ? I want to do it small... (5 Replies)
Discussion started by: mahesh shinde
5 Replies

3. Shell Programming and Scripting

Renaming files

Hello, I am looking for a command line that will rename name files : f700_abc_o_t_MASTERID_AS_AE_20130323.csv like this f700_abc_o_t_MASTERID_AS_AE_20130324.csv The great idea could be to get the date stamp 20130323 and change any part of it, instead of just change the... (4 Replies)
Discussion started by: Aswex
4 Replies

4. Shell Programming and Scripting

Finding 50k Keywords in 3k files

Hi, I have a file with about 50k keywords. I have a requirement to scan about 3k files to identify which filename has which keyword i.e. an output like following: File1,Keyword1 File1,Keyword2 File3,Keyword1 ..... I have written a shell script which takes each of the 3k files, searches... (4 Replies)
Discussion started by: rjains
4 Replies

5. UNIX for Dummies Questions & Answers

Renaming Files

I just used wget to obtain a bunch of html documents. Now they are named index.html, index.html.1, index.html.2, etc. I'd simply like to move the 1, 2, 3 etc. to the left before the .html, so the new names would be: index1.html, index2.html etc. I know this can be done with a simple script, but... (2 Replies)
Discussion started by: crl21
2 Replies

6. Shell Programming and Scripting

Renaming files

Can someone please help. Much appreciated!! I have 4 directories, for ex... /RUN1/ReportTable.nxt /RUN2/ReportTable.nxt /RUN3/ReportTable.nxt /RUN4/ReportTable.nxt I would like to write a for loop, to add the directory name to each ReportTable.nxt I would like for it to be: ... (5 Replies)
Discussion started by: dirttysoufff
5 Replies

7. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

8. UNIX for Dummies Questions & Answers

Need help renaming files

I just can't figure this one out. I have a lot of files name (for example) ABC1234.5678.ext I need to rename these files U0105678PQRS So I'm removing everything before the first "." I'm keeping "5678" in the file name Adding "U010" to the front of "5678" Dropping the ".ext" extension ... (5 Replies)
Discussion started by: bbbngowc
5 Replies

9. Shell Programming and Scripting

renaming Files

Renaming Files more than 1000 in Diffrent Directories in system.. help me in this issue to resolve.... (5 Replies)
Discussion started by: sunsap
5 Replies

10. Shell Programming and Scripting

Perl: sorting files by whats in'em

i'm halfway into my script and realize i may need to use an associative array (a hash, i guess they are called in Perl). i'm fairly new to Perl and don't know how to use them correctly. i have some files in a directory. each file contains a number in a specific place in it's header. what i would... (4 Replies)
Discussion started by: quantumechanix
4 Replies
Login or Register to Ask a Question