Moving files and changing names


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Moving files and changing names
# 1  
Old 11-17-2006
Moving files and changing names

i have many files with extention filename.ASN_ERROR~ at a path. I want to move these files to another path and change extension to .ASN

There are more then 80,000 files so i cant use manual commands

muneebr
# 2  
Old 11-17-2006
Java

The mmv command can do this, if you have it installed. It's really useful, I reccomend it. Note that if you're moving to a different device, you'll need to use 'mmv -x'.
Code:
mmv '*.ASN_ERROR~' '/output/path/#1.ASN'

If not, you might have to silly things like piping the output of ls through grep and sed:

Code:
ls /path/to/files | grep "ASN_ERROR~$" | 
        while read FILE
        do
                OUT=`echo "${FILE}" | sed "s/ASN_ERROR~/ASN/;s/^/\/output\/path/"`
                mv "${FILE}" "${OUT}"
        done

# 3  
Old 11-17-2006
If you're using ksh (NOT TESTED):
Code:
cd /path/to/file/
for myfile in *.ASN_ERROR~; do
  mv $myfile /new/path/${myfile%_ERROR~}
done

# 4  
Old 11-17-2006
Won't work. I think you missed the part where he said there were 80,000 of these. There is no way that 80,000 things can fit on one commandline.
# 5  
Old 11-17-2006
Yeah, you're right. I forgot that the * wildcard would try to expand to 80,000 files.
# 6  
Old 11-20-2006
Try this one to improve the performanace

ls -a ./*log | sed -n 's/\(.*\)log/mv \1log \1log123/p' | xargs -I {} ksh -c {}


instead of log use ur matching characters,

Cheers,
nilesh
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing file names

sac_pzs_iv_epoz_hhe__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_epoz_hhn__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_epoz_hhz__2013.074.14.40.46.0000_2599.365.23.59.59.99999 sac_pzs_iv_haga_hhe__2006.111.00.00.00.0000_2599.365.23.59.59.99999... (3 Replies)
Discussion started by: kristinu
3 Replies

2. Shell Programming and Scripting

Changing file names

I have a series of files as follows file-1.pdf file-2.pdf file-3.pdf file-4.pdf file-5.pdf file-6.pdf file-7.pdf I want to have the file names with odd numbers starting from an initial number, for example 2000. The result would be the following: file-2001.pdf file-2003.pdf... (9 Replies)
Discussion started by: kristinu
9 Replies

3. Shell Programming and Scripting

Changing file names

I have file names as shown and want to change the name to have only the first four numbers. /home/chrisd/Desktop/nips/nips_2013/5212-learning-feature-selection-dependencies-in-multi-task-learning.pdf /home/chrisd/Desktop/nips/nips_2013/5213-parametric-task-learning.pdf... (3 Replies)
Discussion started by: kristinu
3 Replies

4. UNIX for Dummies Questions & Answers

Moving files with specific names

Hi, I have a list of names (in a text file) like this: SRR1234 SRR5678 SRR4321 SRR8876 I'd like to have a unix code to find all the files which have any of above strings in their name and move them to a specific directory. I have my files distributed in many subdirectories so it has to... (3 Replies)
Discussion started by: a_bahreini
3 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Writing a loop to changing the names of files in a directory

Hi, I would like to write a loop to change the names of files in a directory. The files are called data1.txt through data1000.txt. I'd like to change their names to a1.txt through a1000.txt. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

7. Shell Programming and Scripting

Moving files and changing name

So I am trying to get my juices flowing on another korn shell scripting project I need to do. I hope my examples here will allow someone to get me pointed in the right direction. I hope I am clear with what I am trying to do. Example: /incomplete/file1v1c1 /incomplete/temp1v1c1... (2 Replies)
Discussion started by: linuxn00b
2 Replies

8. Shell Programming and Scripting

Help with moving files with same names from subdirectories?

I was wondering if someone could help me with this: I have multiple directories and subdirectories with files in them. I need to move all files from all directories and subdirectories into one root directory. However, when i do find /home/user -mindepth 1 -iname "*" -type f -exec mv {} . \; ... (3 Replies)
Discussion started by: r4v3n
3 Replies

9. Shell Programming and Scripting

Changing file names

I have lot of files whose names are something like the following. I want to change the name of all the files from 'npt02' to 'n02'. npt02-z30-sr65-rgdt0p50-dc0p01-16x12drw.tpf npt02-z30-sr65-rgdt0p50-dc0p01-8x6drw.back npt02-z30-sr65-rgdt0p50-dc0p01-8x6drw-bst-mis.xy... (5 Replies)
Discussion started by: kristinu
5 Replies

10. Shell Programming and Scripting

Changing names

I have file names m04-npt06-z30-syn.ps m04-npt06-dp018-8x6smp.vmod m04-npt06-sr40-syn-dp01-16x12drw.params m04-npt06-sr40-syn-dp008-16x12drw.params m04-npt06-sr40-syn-dp008-16x12drw.vmod m04-npt06-sr40-syn-dp008-16x12drw.bck m04-npt06-sr40-syn-dp008-16x12drw.exp... (6 Replies)
Discussion started by: kristinu
6 Replies
Login or Register to Ask a Question