hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Copy or Rename files *.JPG as *.jpg
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

Copy or Rename files *.JPG as *.jpg

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-12-2010, 12:14 PM
hbhb hbhb is offline
Web Hosting Evangelist
 
Join Date: Apr 2006
Posts: 509

Copy or Rename files *.JPG as *.jpg


I have hundreds of files with a .JPG extension on a directory.

I wanted to mass-copy or rename it as .jpg (small case), without overwriting existing file (if file exist)

For example:
abc.JPG -> abc.jpg (Fail: file exist)
abc.jpg
xyz.JPG -> xyz.jpg (Success)

Anyone can help? I try to search for the right command or script to do that but to no avail..

Reply With Quote


Sponsored Links
  #2  
Old 09-12-2010, 12:53 PM
helpyoulinux helpyoulinux is offline
WHT Addict
 
Join Date: May 2008
Location: Sweden
Posts: 152
I hope you are using a *NIX based machine.


Here you go.

for i in $(ls -1 *.JPG)
do
pre=$(echo $i | cut -d "." -f1)
cp -v $i ${pre}.jpg
done



Please run it on bash.

__________________
Linux, C, Perl, Bash, PHP
MySQL, PostgreSQL
Postfix, Qmail
Bind

Reply With Quote
  #3  
Old 09-12-2010, 01:02 PM
helpyoulinux helpyoulinux is offline
WHT Addict
 
Join Date: May 2008
Location: Sweden
Posts: 152
This is for copying , if you want to rename use mv instead of cp

__________________
Linux, C, Perl, Bash, PHP
MySQL, PostgreSQL
Postfix, Qmail
Bind

Reply With Quote
Sponsored Links
  #4  
Old 09-12-2010, 02:08 PM
hbhb hbhb is offline
Web Hosting Evangelist
 
Join Date: Apr 2006
Posts: 509
will it prompt question to overwrite file (y/n?) because i have over 500 files

Reply With Quote
  #5  
Old 09-12-2010, 02:53 PM
helpyoulinux helpyoulinux is offline
WHT Addict
 
Join Date: May 2008
Location: Sweden
Posts: 152
In that case, you have to use

cp -f

it will do the trick.

__________________
Linux, C, Perl, Bash, PHP
MySQL, PostgreSQL
Postfix, Qmail
Bind

Reply With Quote
  #6  
Old 09-12-2010, 11:30 PM
hbhb hbhb is offline
Web Hosting Evangelist
 
Join Date: Apr 2006
Posts: 509
Supposely I do not want it to overwrite file. Default answer should be a 'NO'

-f sounds like 'force' to 'YES' ?

Reply With Quote
  #7  
Old 09-13-2010, 08:02 PM
LnxtecH LnxtecH is offline
Web Hosting Evangelist
 
Join Date: Jul 2005
Posts: 470
If you do not want to overwrite then use the command
Quote:
yes n | cp source destination

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Quick $20 Paypal (header.jpg and footer.jpg) bizbla Design Requests 2 03-25-2009 11:15 PM
Which software is the best to convert multiple big .jpg to much smaller .jpg for web? drti Web Design and Content 7 11-15-2004 09:06 PM

Related posts from TheWhir.com
Title Type Date Posted
Malwarebytes Launches Data Scan-and-Backup Service Web Hosting News 2013-05-07 14:51:03
Zetta Launches Appliance-Free Hybrid Smart Cloud Backup Solution Web Hosting News 2012-10-23 16:29:27
Website usability – 10 tips for getting it right Blog 2012-04-27 14:11:03
Web Host Hosting Ireland Launches Online Backup Service CloudBox Web Hosting News 2011-09-27 20:00:52
Apple Confirms Discontinuation of iWeb, MobileMe Hosting in 2012 Web Hosting News 2011-06-24 20:15:37


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?