The UNIX and Linux Forums  


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
find the length of file names in a directory? koti_rama Shell Programming and Scripting 5 06-04-2008 11:19 AM
Replace characters in all file names in a particular directory madhunk Shell Programming and Scripting 4 02-16-2006 07:10 PM
directory names in a flat file surjyap Shell Programming and Scripting 2 10-06-2005 08:51 AM
How to change automatically the file names MAKY Shell Programming and Scripting 6 08-10-2005 11:47 AM
File and Directory Names become hidden dbinsol1 UNIX for Advanced & Expert Users 10 05-29-2002 10:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-22-2008
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Quote:
Originally Posted by andou View Post
I tried this with a test directory of 17 Randomly named files. The result was sh: test: too many arguments 13 times and sh: test: Photo: binary operator expected 2 times. However, 2 of the files came out as expected: FILE002 and FILE003.

Sidenote: This is with .jpg files. I changed "FILE%03i" to "FILE%03i.jpg", so the two files came out: FILE002.jpg and FILE003.jpg. None of the other file names changed.
I think you have spaces in your filenames, which my script didn't handle. It's simple to fix by putting double-quotes around filenames....
Code:
c=0
for i in *.jpg
do 
   test -f "$i" &&\
   mv "$i" $(printf "FILE%03i.jpg" $c) &&\
   ((c+=1))
done

Last edited by Ygor; 01-22-2008 at 08:53 PM..
  #2 (permalink)  
Old 01-22-2008
andou andou is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 20
Worked like a charm!~

Thanks Ygor

And thanks everyone for the great replies ^^
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 07:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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