Sponsored Content
Top Forums UNIX for Dummies Questions & Answers rename multiple files from search output Post 302274103 by woodstock on Tuesday 6th of January 2009 04:51:18 PM
Old 01-06-2009
Thanks for your suggestions folks. Handy forum. I've not tried perl before but will have a read up. I think for the time being i will stick with the "for i" & "while" methods for this though.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Rename multiple files

Hello, I want to rename multiple files at a time and I don't know how to do it. I have various ".mp3" files, like "band name - music name.mp3" and I want to remove the "band name" from all files. Anybody knows how to do it using shell script or sed or even perl? Thanks (7 Replies)
Discussion started by: luiz_fer10
7 Replies

2. Shell Programming and Scripting

rename multiple files

Hi, can anyone have a ksh script to rename multiple files (ie to remove .Z extension of the files) can someone correct this? for i in *.Z do var1 = substr($i, 1,at(".Z",$i)-1) mv $i $var1 done Thanks.. Antony (13 Replies)
Discussion started by: antointoronto
13 Replies

3. Shell Programming and Scripting

now to rename multiple files

I have several hundred files in one directory which I need to move to another directory with the new extension, for example: /bb/data/rptmgr* are in the source directory need to be moved to /bb/data55/rptmgr*.new Is there an efficient way to do it? Thanks -A (4 Replies)
Discussion started by: aoussenko
4 Replies

4. UNIX for Dummies Questions & Answers

How to rename multiple files

Hi all, I have some files like: pickup.0000043200.t001.t001.data pickup.0000043200.t001.t002.data pickup.0000043200.t002.t001.data pickup.0000043200.t002.t002.data pickup.0000043200.t003.t001.data pickup.0000043200.t003.t002.data I need to rename these files to ... (4 Replies)
Discussion started by: a_dor8
4 Replies

5. Shell Programming and Scripting

Rename the multiple files

Hi I need to reanme the multiple file using unix script I have multiple file like: sample_YYYYMMDD.xls test new_YYYYMMDD.xls simple_YYYYMMDD.xls I need to rename this file sample.xls testnew.xls SIMPLE.xls thanks (8 Replies)
Discussion started by: murari83.ds
8 Replies

6. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

7. Shell Programming and Scripting

Script to unzip files and Rename the Output-files

Hi all, I have a many folders with zipped files in them. The zipped files are txt files from different folders. The txt files have the same names. If i try to find . -type f -name "*.zip" -exec cp -R {} /myhome/ZIP \; it fails since the ZIP files from different folders have the same names and... (2 Replies)
Discussion started by: pmkenya
2 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Search, Extract and Rename Multiple Files

Hi, I want perl script for the below requirement. We have lot of files like below name in the directory 750464921-RE-file2.csv 750452173-RE-file1.csv 750385426-RE-file3.csv 750373470-RE-file4.csv And also we have another file as "Group.csv" in the same directory as per the below format... (9 Replies)
Discussion started by: armsaran
9 Replies

9. Shell Programming and Scripting

How to rename multiple files at one go?

Hi, I have hundreds of files with XXX in their file name and I want to rename all of them with YYY in place of XXX. for ex: $ ls -1 123XXX789 345XXX678 Output $ ls -1 123YYY789 345YYY678 I know we can loop in each file and sed to replace and rename each file but ren *XXX* *YYY*... (4 Replies)
Discussion started by: reddyr
4 Replies

10. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies
rename(2)							System Calls Manual							 rename(2)

NAME
rename - Renames a directory or a file within a file system SYNOPSIS
#include <stdio.h> int rename ( const char *from, const char *to ); [Tru64 UNIX] The following definition of the rename() function does not conform to current standards and is supported only for backward compatibility (see standards(5)): int rename ( char *from, char *to ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: rename(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Identifies the file or directory to be renamed. Identifies the new pathname of the file or directory to be renamed. If the to parameter is an existing file or empty directory, it is replaced by the from parameter. If the to parameter is a nonempty directory, the rename() func- tion exits with an error. DESCRIPTION
The rename() function renames a directory or a file within a file system. For rename() to complete successfully, the calling process must have write and search permission to the parent directories of both the from and to parameters. If the from parameter is a directory and the parent directories of from and to are different, then the calling process must have write and search permission to the from parameter as well. If the from and to parameters both refer to the same existing file, the rename() function returns successfully and performs no other action. Both the from and to parameters must be of the same type (that is, both directories or both nondirectories) and must reside on the same file system. If the to parameter already exists, it is first removed. In this case it is guaranteed that a link named the to parameter will exist throughout the operation. This link refers to the file named by either the to or from parameter before the operation began. If the final component of the from parameter is a symbolic link, the symbolic link (not the file or directory to which it points) is renamed. If the final component of the to parameter is a symbolic link, the symbolic link is destroyed. If the from and to parameters name directories, the following must be true: The from parameter is not an ancestor of the to parameter. For example, the to pathname must not contain a path prefix that names from. The from parameter is well-formed. For example, the . (dot) entry in from, if it exists, refers to the same directory as from, exactly one directory has a link to from (excluding the self-referential . ), and the .. (dot-dot) entry in from, if it exists, refers to the directory that contains an entry for from. The to parameter, if it exists, must be well-formed (as defined previously). Upon successful completion, the rename() function marks the st_ctime and st_mtime fields of the parent directory of each file for update. RETURN VALUES
Upon successful completion, the rename() function returns a value of 0 (zero). Otherwise, a value of -1 is returned, and errno is set to indicate the error. ERRORS
If the rename() function fails, the file or directory name remains unchanged and errno may be set to one of the following values: Creating the requested link requires writing in a directory with a mode that denies write permission, or a component of either pathname denies search permission. The directory named by the from or to parameter is currently in use by the system or by another process. The directory that would contain to cannot be extended because the user's quota of disk blocks on the file system containing the directory is exhausted. The to parameter is an existing nonempty directory. Either the to or from parameter is an invalid address. Either the from or to parame- ter is not a well-formed directory, an attempt is made to rename . (dot) or .. (dot-dot), or the from parameter is an ancestor of the to parameter. [Tru64 UNIX] An I/O error occurred when updating the (underlined) directory. The to parameter names a directory and the from parameter names a nondirectory. Too many links were encountered in translating either to or from. The length of the to or from parameters exceeds PATH_MAX or a pathname component is longer than NAME_MAX. Indicates either that the system file table is full, or that there are too many files currently open in the system. A component of either path does not exist, or either path is the empty string, or the file named by the from parameter does not exist. The directory that would contain to cannot be extended because the file system is out of space. The from parameter names a directory and the to parameter names a nondirectory. The S_ISVTX flag is set on the directory contain- ing the file to be renamed, and the caller is not the file owner. The requested operation requires writing in a directory on a read-only file system. The link named by the to parameter and the file named by the from parameter are on different file systems. RELATED INFORMATION
Commands: chmod(1), mkdir(1), mv(1), mvdir(1) Functions: chmod(2), link(2), mkdir(2), rmdir(2), unlink(2) Standards: standards(5) delim off rename(2)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy