Sponsored Content
Full Discussion: Changing file names
Top Forums Shell Programming and Scripting Changing file names Post 302492230 by methyl on Sunday 30th of January 2011 02:53:28 PM
Old 01-30-2011
Another way, which should work for large numbers of files and also for filenames containing space characters:

Code:
ls npt02* | while read old_filename
do
        new_filename="echo "${filename}|sed -e "s/npt02/n02/g"
        mv "${old_filename}" "${new_filename}"
done


Last edited by methyl; 01-30-2011 at 03:56 PM.. Reason: many typos
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

changing file names to lowercase

hey guys having some trouble figuring this out. my program is supposed to take a name of a directory as a command line argument and change the filenames inside that directory to lowercase. what i dont get is how you access that directory and go thru all the files and change the filenames... (1 Reply)
Discussion started by: 30177005
1 Replies

2. UNIX for Dummies Questions & Answers

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 (5 Replies)
Discussion started by: muneebr
5 Replies

3. Shell Programming and Scripting

Changing file names with AWK

Dear All, I have some thousands of files in a folder and i need to change those file names without opening the file (no need to change anything in the file content, need to change the file name only). The filenames are as follows: Myfile_name.1_parameter Myfile_name.2_parameter... (6 Replies)
Discussion started by: Fredrick
6 Replies

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

5. Shell Programming and Scripting

[SOLVED] Changing file names

I have written a csh script that changes the name of file from src to dst. I am getting the error below: TESTAmvfiles DONE TESTAmvfiles set: Variable name must begin with a letter. The csh script is: #!/bin/csh #... (0 Replies)
Discussion started by: kristinu
0 Replies

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

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

8. UNIX for Dummies Questions & Answers

Bulk changing of file names using Terminal in OS X

I want to change the name of several files within a folders (directory) and subdirectories in OS X. If I only wanted to change file names within the directory I guess I would use: rm photo*.jpg picture*.jpg I have lots of subdirectories, is there a way of getting the file changes for all... (5 Replies)
Discussion started by: ademanuele
5 Replies

9. Debian

Changing file extension names

Hi I have a list of files :root@L28mustang:/var/log/exim4/2017/Jul2017_Blast_BC07# ls -lrt | grep mainlog -rw-r----- 1 Debian-exim adm 3636932 Jul 8 06:25 mainlog.3.gz -rw-r----- 1 Debian-exim adm 919512 Jul 9 06:27 mainlog.2.gz -rw-r----- 1 Debian-exim adm 7655054 Jul 10 06:25 mainlog.1... (1 Reply)
Discussion started by: anaigini45
1 Replies

10. 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
AnyDBM_File(3pm)					 Perl Programmers Reference Guide					  AnyDBM_File(3pm)

NAME
AnyDBM_File - provide framework for multiple DBMs NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations SYNOPSIS
use AnyDBM_File; DESCRIPTION
This module is a "pure virtual base class"--it has nothing of its own. It's just there to inherit from one of the various DBM packages. It prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See DB_File), GDBM, SDBM (which is always there--it comes with Perl), and finally ODBM. This way old programs that used to use NDBM via dbmopen() can still do so, but new ones can reorder @ISA: BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) } use AnyDBM_File; Having multiple DBM implementations makes it trivial to copy database formats: use Fcntl; use NDBM_File; use DB_File; tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR; tie %oldhash, 'NDBM_File', $old_filename, 1, 0; %newhash = %oldhash; DBM Comparisons Here's a partial table of features the different packages offer: odbm ndbm sdbm gdbm bsd-db ---- ---- ---- ---- ------ Linkage comes w/ perl yes yes yes yes yes Src comes w/ perl no no yes no no Comes w/ many unix os yes yes[0] no no no Builds ok on !unix ? ? yes yes ? Code Size ? ? small big big Database Size ? ? small big? ok[1] Speed ? ? slow ok fast FTPable no no yes yes yes Easy to build N/A N/A yes yes ok[2] Size limits 1k 4k 1k[3] none none Byte-order independent no no no no yes Licensing restrictions ? ? no yes no [0] on mixed universe machines, may be in the bsd compat library, which is often shunned. [1] Can be trimmed if you compile for one access method. [2] See DB_File. Requires symbolic links. [3] By default, but can be redefined. SEE ALSO
dbm(3), ndbm(3), DB_File(3), perldbmfilter perl v5.18.2 2013-11-04 AnyDBM_File(3pm)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy