Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux 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.


  Search this Thread
Old 03-18-2007, 02:17 PM   #1
LQ Newbie
Registered: Mar 2007
Location: Canada
Distribution: Debian
Posts: 6

Rep: Reputation: 0
How to rename file while copying - and remove special characters

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.
Old 03-18-2007, 02:41 PM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735
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
Old 03-19-2007, 12:49 AM   #3
LQ Newbie
Registered: Mar 2007
Location: Canada
Distribution: Debian
Posts: 6

Original Poster
Rep: Reputation: 0
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.
Old 10-11-2007, 05:16 PM   #4
LQ Newbie
Registered: Oct 2007
Location: Edmond, OK
Distribution: Ubuntu
Posts: 6

Rep: Reputation: 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


characters, recursive, rename, renaming, software, special

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
removing file with special characters rsashok Linux - General 4 02-09-2010 05:08 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 06:19 AM.

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