Moving and renaming large ammount of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Moving and renaming large ammount of files
# 1  
Old 12-07-2011
Moving and renaming large ammount of files

Hey, I'm kinda new to the shell scripting and I don't wanna mess things up yet Smilie
Looking for a solution to the following:
I need to move all the files like "filename.failed.dateandtime" to another directory also renaming them "filename.ready". I can't figure how to do this with multiple files and add this to a script. Help will be accepted Smilie
# 2  
Old 12-07-2011
You can always try this in some test/temp directory with some example files so you don't mess up anything. What have you tried so far? Btw, you can always scroll down to the bottom of your thread and see which similar/related threads the forum suggests.
# 3  
Old 12-07-2011
thanks, I rushed before searching. Just of the top of my head will something like this work:
mmv -m *.failed.* /to/here/#1.ready
# 4  
Old 12-07-2011
How about this... Test first!
Code:
for i in `find ./ -name *failed*`
do
    newfn=`echo $i |sed 's/failed.dateandtime/ready/'`
    echo "mv $i /somewhere/$newfn"
    # mv $i /somewhere/$newfn
done


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 12-07-2011 at 05:06 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 12-07-2011
Code:
$ ls -1 *failed* | nawk -F\. '{print "mv "$0" /somewhere/"$1".ready"}' | sh

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script for renaming and moving Files - Easy?

Hey guys, ive been working on this for about 2hrs now - without any solution. At first I need to say I dont have skills in linux bash scripting, but I tried to use some codesnippets and manuals from google. What I want to do: I have different folders including 2 different filestypes with... (15 Replies)
Discussion started by: peter1337
15 Replies

2. UNIX for Dummies Questions & Answers

Moving and renaming files

I have a directory full of directories, say called A B C D E .... In each of these directories there are files called 1.dsp 2.dsp 3.dsp ..... along with others (with different extensions) I need to go through each of these directories and move the dsp file to another folder, but with the name now... (6 Replies)
Discussion started by: claire.a
6 Replies

3. Shell Programming and Scripting

Moving and renaming multiple files in a directory

Hi. I am trying to automate the movement and renaming of a number of files in a directory. I am using the 'mv' command as I do not have access to 'rename'. I have the following scripted FILES=$(ls /transfer/move/sys/mail/20130123/) if ; then for i in ${FILES} ; do mv... (4 Replies)
Discussion started by: jimbojames
4 Replies

4. Shell Programming and Scripting

Complex renaming then moving files

I am a biologist and using an program on a computer cluster that generates a lot of data. The program creates a directory named ExperimentX (where X is a number) that contains files "out.pdb" and "log.txt". I would like to create a script that renames the out.pdb file to out_ExperimentX.pdb (or... (1 Reply)
Discussion started by: yaledocker
1 Replies

5. Shell Programming and Scripting

Need script for renaming and moving files one by one...

Dears, I need your help! I got a problem and found some workaround solution but I donno how to realize it. I have a number of files (about 300 each day) and I need them to be renamed. All these files has fixed number of letters and name looks like this one:... (7 Replies)
Discussion started by: nypreH
7 Replies

6. Shell Programming and Scripting

Need help with shell script for moving/deleting/renaming files

Hi. I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next. Here's an example: /var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Discussion started by: aflower
4 Replies

7. UNIX for Dummies Questions & Answers

Renaming Large Files

When I have a file for example with the wrong name I normally use the cp {filename} {new filename} comand so I will have the original as well as the correct named file. Just for backup purposes. Problem: I have a file that is 24gb with a case sensitive filename. The file was named with upper... (3 Replies)
Discussion started by: trek88
3 Replies

8. Shell Programming and Scripting

moving large number of files

I have a task to move more than 35000 files every two hours, from the same directory to another directory based on a file that has the list of filenames I tried the following logics (1) find . -name \*.dat > list for i in `cat list` do mv $i test/ done (2) cat list|xargs -i mv "{}"... (7 Replies)
Discussion started by: bryan
7 Replies

9. Shell Programming and Scripting

Moving multiple files and renaming them on the fly

Hi All, Being new to scripting I am facing a new situation. We have an application that generates a file lets say dumpfile for each user under the users home directory when they execute the application. This is quite a huge file and imagine having that for over 40 users on a daily basis. The... (1 Reply)
Discussion started by: daemongk
1 Replies

10. Shell Programming and Scripting

moving and renaming multiple files

Greetings, I know i can use the mv command to move and rename one file. How can I do this with multiple files? example pic01.bmp to pic0001.bmp how can i perform this function on an entire directory of sequential files and keep them in sequence? Hints, suggestions are most welcome:) ... (1 Reply)
Discussion started by: rocinante
1 Replies
Login or Register to Ask a Question