12-24-2008
rename multiple files from search output
Variations of multiple renames seems to come up a lot but i can't find the answer to this situation.
Tidying up a directory where people rename files to .working, .bob, .attempt1 & so on.
what i am trying to do is: list the file type, & rename from ".whatever" to .fixed.
As the ".whatever" is rarely the same, it makes this a bit more than the normal rename all ".a's" to ".b's" if you get my drift.
For this particular list of example files i have come up with:
for i in `ls WLAN_* | egrep -v 'TRF|fixed' | cut -d "." -f1`;do mv $i.* $i.fixed;done
which appears to work fine but a tad "around the houses". I was hoping someone knew a better way/shorter command string.
Example files as follows:
1.sh
bla1.txt
bla2.csv
WLAN_20081128_00051453_01.TRF
WLAN_20081128_00051468_01.TRF
WLAN_20081128_00051469_01.TRF
WLAN_20081128_00051470_01.TRF
WLAN_clo_20081202_00051984_01.sg-working2
WLAN_clo_20081129_00051540_01.sg-working
WLAN_clo_20081129_00051580_01.sg-working
WLAN_clo_20081202_00052011_01.still_failed
WLAN_clo_20080923_00043115.done
WLAN_20081128_00051467_01.TRF
WLAN_20081128_00051466_01.TRF
WLAN_20081128_00051465_01.TRF
WLAN_20081128_00051454_01.TRF
WLAN_20081128_00051455_01.TRF
WLAN_20081128_00051456_01.TRF
WLAN_20081128_00051457_01.TRF
WLAN_20081128_00051458_01.TRF
WLAN_20081128_00051459_01.TRF
WLAN_20081128_00051460_01.TRF
WLAN_20081128_00051461_01.fixed
WLAN_20081128_00051462_01.fixed
WLAN_20081128_00051463_01.TRF
WLAN_20081128_00051464_01.TRF
WLAN_clo_20081222_00054519_01.test1-sg
Desired output ( but this was using my command as above)
1.sh
bla1.txt
bla2.csv
WLAN_20081128_00051453_01.TRF
WLAN_20081128_00051468_01.TRF
WLAN_20081128_00051469_01.TRF
WLAN_20081128_00051470_01.TRF
WLAN_clo_20081202_00052011_01.fixed
WLAN_clo_20081129_00051580_01.fixed
WLAN_clo_20081202_00051984_01.fixed
WLAN_clo_20081222_00054519_01.fixed
WLAN_clo_20080923_00043115.fixed
WLAN_20081128_00051467_01.TRF
WLAN_20081128_00051466_01.TRF
WLAN_20081128_00051465_01.TRF
WLAN_20081128_00051454_01.TRF
WLAN_20081128_00051455_01.TRF
WLAN_20081128_00051456_01.TRF
WLAN_20081128_00051457_01.TRF
WLAN_20081128_00051458_01.TRF
WLAN_20081128_00051459_01.TRF
WLAN_20081128_00051460_01.TRF
WLAN_20081128_00051461_01.fixed
WLAN_20081128_00051462_01.fixed
WLAN_20081128_00051463_01.TRF
WLAN_20081128_00051464_01.TRF
WLAN_clo_20081129_00051540_01.fixed
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT OPENSOLARIS
gvfs-rename
gvfs-rename(1) User Commands gvfs-rename(1)
NAME
gvfs-rename - change the name of a file or directory using the VFS system
SYNOPSIS
gvfs-rename source-URI new-name
DESCRIPTION
gvfs-rename changes the name of a file or directory, using the virtual file system.
OPERANDS
The following operands are supported:
source-URI Specifies the source file location in standard URI format.
new-name Specifies the new name for file or directory.
EXAMPLES
Example 1: Rename a Local HTML File
example%
gvfs-rename file:///home/user/index.html file:///home/user/index.html.old
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables: NLSPATH.
EXIT STATUS
The exit value 0 is returned regardless of success or failure.
FILES
The following files are used by this application:
/usr/bin/gvfs-rename Executable to rename a file using the GVFS library
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWgnome-gvfs |
+-----------------------------+-----------------------------+
|Interface stability |Volatile |
+-----------------------------+-----------------------------+
SEE ALSO
gvfs-cat(1), gvfs-copy(1), gvfs-move(1), gvfs-info(1), gvfs-less(1), gvfs-ls(1), gvfs-mkdir(1) gvfs-monitor-dir(1), gvfs-monitor-file(1),
gvfs-mount(1), gvfs-copy(1), gvfs-open(1), gvfs-rm(1), gvfs-save(1), gvfs-trash(1), gvfs-tree(1), attributes(5), environ(5)
NOTES
Written by Alvaro Lopez Ortega, Sun Microsystems Inc., 2008.
SunOS 5.11 30 May 2008 gvfs-rename(1)