The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SED - editing file names (End of line problem?) busillis Shell Programming and Scripting 1 03-23-2008 08:59 AM
changing multiple directory names w/ sed RahJiggah OS X (Apple) 1 11-05-2007 01:55 PM
editing sqlplus id@passwd in multiple scripts, users and directories Helmi UNIX for Dummies Questions & Answers 8 05-09-2007 12:02 AM
Using Sendmail for multiple domain names captainash UNIX for Dummies Questions & Answers 1 01-16-2004 12:28 PM
Editing one string in multiple files Skoshi UNIX for Dummies Questions & Answers 1 11-10-2001 02:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2007
KeesH KeesH is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 41
Editing multiple file names in one go

Hi there,

I have a folder full of pdf's and I've run a compression on the to reduce the size, the output of the compress places a '-o' in the name of the file.

Before 12345.pdf
After 12345-o.pdf

Now I've got around 50000 files that I need to change back to the previous name, is there a script that can be used to do this?

Any help is much appriciated.

Regards
Kees
  #2 (permalink)  
Old 10-05-2007
harim harim is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 5
in Unix.

there is no command for renaming

use can mv command

mv oldfilename newfilename

  #3 (permalink)  
Old 10-05-2007
lorcan lorcan is offline
Registered User
  
 

Join Date: May 2007
Posts: 219
Try some things like

Code:
#!/bin/ksh

INPUT_DIR="/home/"
for file in $(ls $INPUT_DIR/*-o.pdf)
do
        new_file=$(echo ${file%%-o.pdf})
        new_file=${new_file}.pdf
        mv $file $new_file
done
  #4 (permalink)  
Old 10-06-2007
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,930
Code:
ls *o.pdf  | while read file
do
 mv "$file" `echo $file | sed 's/-o//'`
done
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0