Sponsored Content
Top Forums Shell Programming and Scripting how to rename a number of files Post 302312281 by cfajohnson on Thursday 30th of April 2009 09:27:45 PM
Old 04-30-2009
Quote:
Originally Posted by giannicello
Code:
ls *.R 2>/dev/null|while read file_nm ; do
 echo mv $file_nm ${file_nm%.*}
done


Not only is ls unnecessary, but it will break the script if any filenames contain spaces.

The filenames should be quoted:
Code:
for file in *.R ; do
 echo mv "$file" "${file%.R}"
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to rename files?

:confused: How can i rename a file 'x.log' to 'x_20020512 072909.log' :eek: i'm using perl, with system command from a unix web server, and need to timestamp my logs if the above format (filename _ year month day hr min sec .log) (9 Replies)
Discussion started by: CompuTelSystem
9 Replies

2. UNIX for Dummies Questions & Answers

Rename a number of files using grep

Hi all, I'm trying to rename a directory of html-files: index.php?page=start should become start.html I've lost track of all the pipes and brackets and decided I need some help ;-) Many thanks. (4 Replies)
Discussion started by: TylerDurden
4 Replies

3. Shell Programming and Scripting

rename files

hey all, I have files in the format of ABCD20061101 and ABCDEF20061101 in one directory, I would like to change all ABCD20061101 to ABCDEF20061101 and the problem is if I do a simple pattern match of ABCD, then those ABCDEF20061101 would also... (2 Replies)
Discussion started by: mpang_
2 Replies

4. Shell Programming and Scripting

rename files Ax based on strings found in files Bx

Hi, I'm not very experienced in shell scripting and that's probably why I came across the following problem: I do have several hundred pairs of text files (PF00x.spl and PF00x.shd) where the first file (PF00x.spl) needs to be renamed according a string that is included in the second file... (12 Replies)
Discussion started by: inCH
12 Replies

5. UNIX for Dummies Questions & Answers

Rename all .sh files to .pl

I have various .sh and .pl files in one directory. I want to rename all the .sh files to .pl i.e testscript.sh --> testscript.pl I am trying to use mv *.sh *.pl It doesnt work though!! (3 Replies)
Discussion started by: chrisjones
3 Replies

6. UNIX for Dummies Questions & Answers

Rename a large number of files in subdirectories

Hi, I have a large number of subdirectories (>200), and in each of these directories there is a file with a name like "opp1234.dat". I'd like to know how I could change the names of these files to say "out.dat" in all these subdirectories in one go. Thanks! (5 Replies)
Discussion started by: lost.identity
5 Replies

7. Shell Programming and Scripting

How to count number of files in directory and write to new file with number of files and their name?

Hi! I just want to count number of files in a directory, and write to new text file, with number of files and their name output should look like this,, assume that below one is a new file created by script Number of files in directory = 25 1. a.txt 2. abc.txt 3. asd.dat... (20 Replies)
Discussion started by: Akshay Hegde
20 Replies

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

9. Shell Programming and Scripting

List files with number to select based on number

Hi experts, I am using KSH and I am need to display file with number in front of file names and user can select it by entering the number. I am trying to use following command to display list with numbers. but I do not know how to capture number and identify what file it is to be used for... (5 Replies)
Discussion started by: mysocks
5 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
xmlindent(1)															      xmlindent(1)

NAME
xmlindent - XML stream reformatter SYNTAX
xmlindent [-o output file] [-i indent level] [-l max columns] [-n newline position] [-t] [-c] [-f] [-w] [-h] [-v] DESCRIPTION
XML Indent is a XML stream reformatter written in ANSI C. It is analogous to GNU indent. OPTIONS
-o output file Write indented XML to output file -i indent level Indent each level indent level spaces deeper -l max columns Wrap lines longer than max columns -t Use tabs instead of spaces -nas Suppress newline after start-tag -nae Suppress newline after end-tag -nbs Suppress newline before start-tag -nbe Suppress newline before end-tag -f Force newline on elements without children -w Overwrite original file -v Show version -h Show command line help AUTHORS
Pekka Enberg <penberg@iki.fi> Thomas Fischer <th.fischer@gmx.net> (man page) SEE ALSO
indent(1) Thomas Fischer 0.2.17 xmlindent(1)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy