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
Need help renaming files bbbngowc UNIX for Dummies Questions & Answers 5 04-23-2008 02:08 PM
Renaming Files abch624 Shell Programming and Scripting 2 03-20-2008 12:54 AM
renaming files jxh461 UNIX for Dummies Questions & Answers 1 02-04-2008 09:32 PM
renaming files systemsb UNIX for Dummies Questions & Answers 3 05-25-2006 12:56 AM
renaming files raguramtgr UNIX for Dummies Questions & Answers 4 09-21-2004 10:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-20-2007
Tygoon Tygoon is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 3
Renaming files

Hello!
I am not familiar with UNIX and I have this problem:

I need to move files from a UNIX machine to a PC. UNIX file names contain ":" as special character which is not recognized in a PC.
How can I change ":" for "_" in the name of a bunch of files in UNIX?

Thanks for your help.

Last edited by Tygoon; 12-20-2007 at 09:30 PM..
  #2 (permalink)  
Old 12-20-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Code:
for file in *
do
  mv $file `echo $file | sed 's/\:/_/g'`
done
  #3 (permalink)  
Old 12-20-2007
Tygoon Tygoon is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 3
Thank you for your help!
  #4 (permalink)  
Old 12-21-2007
Tygoon Tygoon is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 3
How to includes files and folder inside a folder

Hi!
I tried the procedure described and I could change the file names inside the main folder. I would like this process to include any subfolders and files included in the main folder (and not repeating it in each folder!).
Thanks!
  #5 (permalink)  
Old 12-25-2007
mehmet_demirez mehmet_demirez is offline
Registered User
  
 

Join Date: Dec 2007
Location: Istanbul
Posts: 23
Quote:
Originally Posted by Tygoon View Post
Hi!
I tried the procedure described and I could change the file names inside the main folder. I would like this process to include any subfolders and files included in the main folder (and not repeating it in each folder!).
Thanks!
extending previous solution for subfolders:

for file in `find .`
do
mv $file `echo $file | sed 's/:/_/g'`
done
  #6 (permalink)  
Old 01-06-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by mehmet_demirez View Post
extending previous solution for subfolders:

for file in `find .`
do
mv $file `echo $file | sed 's/:/_/g'`
done
I'd suggest adding a '-type f' to the find command to to avoid it matching directories too?
  #7 (permalink)  
Old 01-06-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,507
Quote:
Originally Posted by Smiling Dragon View Post
I'd suggest adding a '-type f' to the find command to to avoid it matching directories too?
i would suggest using while loop instead. ( although it should be ok with a for loop if files with spaces are properly parsed)
Code:
# find . -type f | while read line;  do .... ; 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 12:51 AM.


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