Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Rename a large number of files in subdirectories Post 302634351 by rbatte1 on Thursday 3rd of May 2012 08:38:35 AM
Old 05-03-2012
Try
Code:
#!/bin/ksh
for foundfile in `find $dir -name "opp[0-9][0-9][0-9][0-9].dat" -print`
do
   filedir="${file%/*}"
   echo mv $foundfile $filedir/out.dat
done

This will only display, so you can have a play to vary it. Just remove the echo word to execute for real when you are happy. The code looks for all files under $dir so you can choose what to substitute for that. It only picks up files which are the letters opp followed by four digits, followed by .dat, so if this doesn't quite match what you need, you will need to tweak that too.



I hope that this helps,
Robin
Liverpool/Blackburn
UK
This User Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Count number of files in subdirectories

Hello, I am new to unix and would like to have a count of all the files in the current directory as well as all the files in a subdirectory. The command I used was ls -R | wc -l but the number returned wasn't correct. Can someone please help? Thanks (2 Replies)
Discussion started by: cbeverly
2 Replies

2. 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

3. Shell Programming and Scripting

how to rename a number of files

Hi I need to rename about hundred of files which contain ".R " and the end, for example: /t1/data/f2993trn.ix7.R The new file should not have ".R" extension, ex: /t1/data/f2993trn.ix7.R Is there a command which I can put in the loop to do this? Thansk for any advice -A (6 Replies)
Discussion started by: aoussenko
6 Replies

4. Shell Programming and Scripting

Concatenation of a large number of files

Hellow i have a large number of files that i want to concatenate to one. these files start with the word 'VOICE_' for example VOICE_0000000000 VOICE_1223o23u0 VOICE_934934927349 I use the following code: cat /ODS/prepaid/CDR_FLOW/MEDIATION/VOICE_* >> /ODS/prepaid/CDR_FLOW/WORK/VOICE ... (10 Replies)
Discussion started by: chriss_58
10 Replies

5. Shell Programming and Scripting

how can i find number of lines in files & subdirectories

how can i find number of lines in files & subdirectories ? (3 Replies)
Discussion started by: pcbuilder
3 Replies

6. UNIX for Dummies Questions & Answers

Delete large number of files

Hi. I need to delete a large number of files listed in a txt file. There are over 90000 files in the list. Some of the directory names and some of the file names do have spaces in them. In the file, each line is a full path to a file: /path/to/the files/file1 /path/to/some other/files/file 2... (4 Replies)
Discussion started by: inakajin
4 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

9. Shell Programming and Scripting

Sftp large number of files

Want to sftp large number of files ... approx 150 files will come to server every minute. (AIX box) Also need make sure file has been sftped successfully... Please let me know : 1. What is the best / faster way to transfer files? 2. should I use batch option -b so that connectivity will be... (3 Replies)
Discussion started by: vegasluxor
3 Replies

10. UNIX for Dummies Questions & Answers

UNIX - command to count number of files in subdirectories

I have a folder named test/ and under that I have multiple directories and in each of the directory I have multiple log files. I want to know how many files exists under each sub directory. test |--quanrantine |--logfile1 |--logfile2 |--spooling |--logfile1 ... (4 Replies)
Discussion started by: ravikirankethe
4 Replies
dohash(8)						      System Manager's Manual							 dohash(8)

NAME
dohash, undohash - Hashes or unhashes IMAP configuration directories SYNOPSIS
/usr/sbin/dohash [-f] [-h] [-i] /usr/sbin/undohash OPTIONS
The following options are available only for the dohash command: Forces the hashing process to continue even if the command encounters errors. Prints a usage message for the command. Runs the hashing process interactively. DESCRIPTION
The dohash command converts the IMAP configuration directories from the format for older versions of the Cyrus IMAP4 Revision 1 server to the new format for Version 1.6.1 or higher. Starting with Version 1.6.1 of the server, the IMAP user files in the quota and user directories are stored in a through z subdirectories, sorted by the first character of each user name. This arrangement reduces the number of entries in a given directory and consequently increases performance and scalability. The dohash command creates the a through z subdirectories and sorts the existing IMAP files as described; the undohash command reverses this process, in case you need to revert to a previous version of the server. You can optionally sort the users' directories in the IMAP mail spool in the same manner if you enable the hashimapspool option in the /etc/imapd.conf file before invoking the dohash command. See imapd.conf(4) for more information. Note that you must be logged in as the imap user to use the dohash command; otherwise, the newly-created subdirectories will not have the proper ownership. EXAMPLES
The following example shows output from the dohash command: # /usr/sbin/dohash configuration directory /var/imap... hashing user directory hashing quota directory done hashing In this example, the configuration directory is /var/imap; therefore, you could check that the dohash command has successfully hashed the directories by using the ls command as follows: # ls /var/imap/quota /var/imap/user /var/imap/quota: a b c d e f g h i j k l m n o p q r s t u v w x y z /var/imap/user: a b c d e f g h i j k l m n o p q r s t u v w x y z The slash () indicates line continuation. FILES
Configuration file for the IMAP server. Specifies the location of the IMAP configuration directory. SEE ALSO
Commands: imapd(8) Files: imapd.conf(4) Network Administration dohash(8)
All times are GMT -4. The time now is 09:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy