Sponsored Content
Full Discussion: Renaming a bunch of files
Top Forums Shell Programming and Scripting Renaming a bunch of files Post 302242954 by tokland on Friday 3rd of October 2008 09:11:02 AM
Old 10-03-2008
Quote:
Originally Posted by era
Why not just specify "from to" pairs?

Code:
while read from to; do
  mv "$from" "$to"
done <<HERE
  hello.txt hi.txt
  goodbye.txt seeyou.txt
HERE

Thanks for your reply. I see two problems, though:

- You build by hand the pairs to rename, and this should be automatic. That's why I use paste, to simulate a zip function found in some scripting languages.

- read will fail if the filename contains spaces. This is easily solvable setting IFS to tab.

Using both paste and the while read, we could write:

Code:
paste <(for FILE in "$@"; do echo "$FILE"; done) - | \
    while IFS=$(echo -e "\t") read FROM TO; do mv "$FROM" "$TO"; done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep'ing for text within a bunch of files...?

I have, say, a dozen files, and I want to grep for a string of text within them. I don't remember the exact syntax, but let me give it a shot and show you an idea here... find . -type f -exec grep thisword {} \; ...and there's a way to put more than one grep into the statement, so it will tell... (1 Reply)
Discussion started by: kitykity
1 Replies

2. Shell Programming and Scripting

Renaming a bunch of files

Hi Can any body help me reg. this problem? The problem is the format of the shell script should be >renam old new rename: it renames all files in current directory from old extension to new extension old: it is the old extension of file name (including the '.' ) new: its the new extension ... (2 Replies)
Discussion started by: Prashanth.m
2 Replies

3. UNIX for Dummies Questions & Answers

How do I rename a bunch of files at once?

I have about 3000+ files name P08DDD that I want to rename U08DDD. How can I do this using a single command? (8 Replies)
Discussion started by: bbbngowc
8 Replies

4. Shell Programming and Scripting

Replace Characters for bunch of Files.

Hi, I am new to unix and looking out for some help in reading a file contents and replacing the characters, the requirement is I having a folder and having nearly 300 txt files, all the file contents contains some words we need to iterate all each and every files and need to find and replace it... (1 Reply)
Discussion started by: subrahmaniank
1 Replies

5. Shell Programming and Scripting

Multiple edits to a bunch of html files

I'm trying to upgrade a whole bunch of pages on my site to a new design. I thought one way of doing it would be to enclose the content in special comment tags and then use some form of script to wrap the new html around it. Like this: <!-- content start --> <h1>Blah blah blah</h1> yada yada... (9 Replies)
Discussion started by: dheian
9 Replies

6. Shell Programming and Scripting

Script for adding few methods to bunch of Java files

Hi I have around 1000+ java file under different folder in /home/raxit/source and in each file i want to add a fix method. -------- /* Some comment for few lines like header block etc.. */ package import class A { method1 () { } method2 () (3 Replies)
Discussion started by: raxitsheth
3 Replies

7. UNIX for Dummies Questions & Answers

Grep bunch of gzip files to count based on category

Started using unix commands recently. I have 50 gzip files. I want to grep each of these files for a line count based particular category in column 3. How can I do that? For example Sr.No Date City Description Code Address 1 06/09 NY living here 0909 10st st nyc 2 ... (5 Replies)
Discussion started by: jinxx
5 Replies

8. Shell Programming and Scripting

Remove the first two records from a bunch of files

Hi, i have lots of single-column text files in a directory and i want to remove from each of them the first two lines and print the result in multiple new single-column files. i know that for one file the below tail command would just do the job : tail -n +3 filename > new_filename is there... (4 Replies)
Discussion started by: amarn
4 Replies

9. Shell Programming and Scripting

I need to back up a bunch of files on a directory and save that file as the current date....

this is what i have to find the files modified within the past 24 hours find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar" however i need to save/name this archive as the current date (MM-DD,YYYY.tar.gz) how do i doo this (1 Reply)
Discussion started by: bugenhagen_
1 Replies

10. Shell Programming and Scripting

How to rename bunch of files on sftp?

Hi All, I am trying to move all processed .csv files on sftp to archive dir . I tried to use wildcard *.csv but its not working . Is there any way to do this. I appreciate your help. Regards, raj (1 Reply)
Discussion started by: rajeevm
1 Replies
PPI::Token::QuoteLike(3)				User Contributed Perl Documentation				  PPI::Token::QuoteLike(3)

NAME
PPI::Token::QuoteLike - Quote-like operator abstract base class INHERITANCE
PPI::Token::QuoteLike isa PPI::Token isa PPI::Element DESCRIPTION
The "PPI::Token::QuoteLike" class is never instantiated, and simply provides a common abstract base class for the five quote-like operator classes. In PPI, a "quote-like" is the set of quote-like things that exclude the string quotes and regular expressions. The subclasses of "PPI::Token::QuoteLike" are: qw{} - PPI::Token::QuoteLike::Words `` - PPI::Token::QuoteLike::Backtick qx{} - PPI::Token::QuoteLike::Command qr// - PPI::Token::QuoteLike::Regexp <FOO> - PPI::Token::QuoteLike::Readline The names are hopefully obvious enough not to have to explain what each class is. See their pages for more details. You may note that the backtick and command quote-like are treated separately, even though they do the same thing. This is intentional, as the inherit from and are processed by two different parts of the PPI's quote engine. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.2 2011-02-25 PPI::Token::QuoteLike(3)
All times are GMT -4. The time now is 09:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy