LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux > Linux - General
User Name
Password
Linux - General This forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Tags used in this thread
Popular LQ Tags , , , , , , ,

Reply
 
Thread Tools
Old 03-18-2007, 02:17 PM   #1
corporal79
LQ Newbie
 
Registered: Mar 2007
Location: Canada
Distribution: Debian
Posts: 6
Thanked: 0
How to rename file while copying - and remove special characters


[Log in to get rid of this advertisement]
The nice thing about Linux filesystems is that they support crazy characters like "?" and ":" in filenames. The bad thing is, though, that other, less-free filesystems don't. Case-in-point: an iPod with RockBox installed, which requires a VFAT data partition. So, the real question I'm getting to is this: How can I copy files from my data partition on Linux onto the RockBox iPod, without having to manually remove all the unsupported characters? Thanks.
corporal79 is offline  
Tag This Post , ,
Reply With Quote
Old 03-18-2007, 02:41 PM   #2
pixellany
Moderator
 
Registered: Nov 2005
Location: Pasadena, CA
Distribution: Arch
Posts: 13,172
Thanked: 285
cp <filename> <path><newfilename>

eg: In my home directory, copy "file" to the Desktop with a new name: "newfile"

cp file Desktop/newfile

Take a look at "man cp" for more
pixellany is offline     Reply With Quote
Old 03-19-2007, 12:49 AM   #3
corporal79
LQ Newbie
 
Registered: Mar 2007
Location: Canada
Distribution: Debian
Posts: 6
Thanked: 0

Original Poster
Ah, yeah. I knew that - but such only works for renaming files one at a time. I'm talking about moving several hundred files with enough colons and other characters to make moving them one at a time like that very tedious. So, a better question would be: is there any way that I could move files en masse while replacing (or stripping, for that matter) said characters?

Last edited by corporal79; 03-19-2007 at 03:19 AM..
corporal79 is offline     Reply With Quote
Old 10-11-2007, 05:16 PM   #4
phirestalker
LQ Newbie
 
Registered: Oct 2007
Location: Edmond, OK
Distribution: Ubuntu
Posts: 5
Thanked: 0
well this works for me with a few exceptions: unfortunately it seems find enumerates all it needs to do before starting so when you rename things with it you have to make many passes but it's something I'm using it now

find full-path-to-parent-folder -iname "*" -exec rename -v 's/\:|\*|\?|\"//g' "{}" \;

just type that above line (or copy paste) into the terminal (oh make sure to cd into the directory root of the files in question)

oh P.S. if that gives unknown command rename hopefully you can just do a sudo apt-get install rename to get it

and if you wish to remove dots from the directory names which windows seems to have a problem with over SMB you can use

find full-path-to-parent-folder -type d -exec rename -v 's/\.//g' "{}" \;

Last edited by phirestalker; 10-12-2007 at 07:23 PM.. Reason: found some problems with the originally posted method
phirestalker is offline  
Tag This Post , , , ,
Reply With Quote

Reply

Bookmarks


Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
removing file with special characters rsashok Linux - General 3 02-15-2007 12:07 PM
File Copy Issue-Special Characters fortezza Linux - Software 1 11-14-2005 08:16 AM
Desktop icons of file systems - remove/rename? lefty.crupps MEPIS 2 06-06-2005 09:36 PM
rename file names with " ? characters fishbonz Linux - Newbie 2 05-31-2005 12:20 PM
Convert special characters in text file nyk Linux - Software 1 01-05-2005 04:20 PM


All times are GMT -5. The time now is 05:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration