Rename files in sub directories with sequential numbers
I can rename a file with sequential numbers from 1 to N with this script:
Code:
num=1
for file in *.dat;do
mv "$file" "$(printf "%u" $num).txt"
let num=num+1
done
The script begins with renaming a some.dat file to 1.dat.txt and goes on sequentially renaming other DAT files to 2.dat.txt, 3.dat.txt and so on.
This script works very well on my Linux system when I have one directory with all DAT files in it. But it cannot work when I have a parent directory with sub directories. My directory structure is like this:
Parent Directory and inside parent directory there are 20 more sub directories and inside those sub directories are the DAT files.
Is there any way I can modify the above script so that (I am in my parent directory and run this script) it takes in one sub-directory and renames all the files in that directory in sequential numbers say 1 to N, then goes to another sub-directory and renames from N+1 to M, then goes to third sub-directory and renames from M+1 to X and so on?
i have hundreds of directories that have to be renamed. the directory structure is fairly uniform which makes the scripting a little simpler.
suppose i have many directories like this */*/*/*abc* (in other words i have similar directory names 3 dirs deep that all contain the pattern abc in... (8 Replies)
Hi Unix gurus,
I have a file. I need to insert sequential number at the starting of the file. Fields are delimited by "|". I know the starting number.
Example:
File is as follows
|123|4test|test
|121|2test|test
|x12|1test|test
|vd123|5test|test
starting number is : 120
... (7 Replies)
Hi,
This is what I would like to do.
1. Find all directories named "ByHost" in a specified directory
2. Rename all .plist files inside "ByHost" directories
This is the way I have been able to do it so far.
#!/bin/sh
#
# Rename ByHost files
#
# Thomas Berglund, 13.07.08
# Get the... (2 Replies)
Hello guys,
I was looking for a shell script that removes all the special characters from the files and the subdirectories recursively. I could not locate it any more. Dose any body have a similar script that dose that?
Thanks for the help.
AV (0 Replies)
I have a huge collection of HTML files. They have their own file names with htmlextension. I want to rename each of these files with continuous numbers starting from 1.html till the last count of files. Simply it means that if there are three files like this
abc.html
cdfhg.html
rmbd.htmlthen... (1 Reply)
Hi All,
I am looking for a simple way to write numbers to a file sequentially starting from 1 and ending on a specified upper limit. Example of the output file is below
Example
1
2
3
4
5
.
.
.
.
1000
please let me know the best way to do it. (10 Replies)
Hi,
I have a directory structure like below
Directoryname create time
d1 12:00
d2 12:05
d3 12:08
I want to read the directories based on timestamp.That is oldest directory must be read first and kick off certain process.
... (7 Replies)
Hi all,
I have more than 12000 files in 46 different directories and each directory has 2 sub-directories named “dat” or “gridded”. Dat sub-directories have files with extension “jpg.dat” and gridded sub-directories have files with extension “.jpg”.
I need to... (1 Reply)
I have a file that looks like this:
n1 1
n2 1
n3 1
n4 3
n4 3
n2 5
n2 5
n2 5
n2 5
n3 5
n3 5
n4 6
n7 6
that is a name followed be a descriptive number.
I want to make these numbers sequential starting from 0 but without changing the "neighbours" each name belongs to. So the above... (3 Replies)
Hi,
Friends, i have a requirement where i need to rename my files residing in multiple sub directories and move them to one different directory along with some kind of directory indicator.
For eg:
test--is my parent directory and it has many files such as
a1.txt
a2.txt
a3.txt
... (5 Replies)
Discussion started by: gnnsprapa
5 Replies
LEARN ABOUT HPUX
fcache_seqlimit_system
fcache_seqlimit_system(5) File Formats Manual fcache_seqlimit_system(5)NAME
fcache_seqlimit_system - percentage of file cache that can be consumed by sequential accesses, per system-wide limit
VALUES
Failsafe
Default
Allowed values
The minimum value allowed is The maximum value allowed is
Specify a positive integer value.
DESCRIPTION
This parameter places a system-wide limit on how much memory can be consumed in the file cache by sequential accesses. It is important to
note the relationship between this tunable and the per-file limit tunable, These two tunables, in conjunction, control how much memory in
the file cache can be consumed by sequential accesses.
When sequential accesses to a file has exceeded the per-file limit AND the system-wide limit, the excess file cache pages are paged out.
Note that both limits have to be reached in order for page stealing to occur. For example, a file can exceed its limit if the limit has
not been reached. Similarly, no page stealing occurs if none of the files on the system has exceeded the per-file limit, even if the sys-
tem-wide limit has been hit.
The page stealing feature is specific to improving sequential I/O performance for large files. Limiting file cache memory consumption
helps alleviate memory pressure in the file cache. It also prevents cache wiping -- a single thread sequentially accessing a large file
can wipe out the existing contents of the file cache.
Who is Expected to Change This Tunable?
System administrators that run applications which do large sequential file I/O's. Typically, these files are larger than the size of phys-
ical memory on the system.
Restrictions on Changing
Changes to this tunable take effect immediately.
When Should the Value of This Tunable Be Raised?
When you wish to allow greater file cache consumption due to sequential accesses. Setting and to 100 effectively disables the sequential
access page stealing feature.
What Are the Side Effects of Raising the Value?
Setting the tunable too high may yield poor performance for large sequential I/O's for large files (larger than physical memory size). and
should be tuned appropriately for the anticipated workload.
When Should the Value of This Tunable Be Lowered?
When you wish to limit file cache consumption due to sequential accesses. Setting and to 0 forces sequential access page stealing to
always occur.
What Are the Side Effects of Lowering the Value?
Could cause more pageouts to occur in an attempt to limit the file cache consumption.
What Other Tunable Values Should Be Changed at the Same Time?
and should be changed at the same time.
WARNINGS
All HP-UX kernel tunable parameters are release specific. This parameter may be removed or have its meaning changed in future releases of
HP-UX.
Installation of optional kernel software, from HP or other vendors, may cause changes to tunable parameter values. After installation,
some tunable parameters may no longer be at the default or recommended values. For information about the effects of installation on tun-
able values, consult the documentation for the kernel software being installed. For information about optional kernel software that was
factory installed on your system, see at
AUTHOR
was developed by HP.
SEE ALSO fcache_seqlimit_file(5).
Tunable Kernel Parameters fcache_seqlimit_system(5)