LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Replacing characters in file names? (http://www.linuxquestions.org/questions/linux-software-2/replacing-characters-in-file-names-436802/)

yuccabrevifolia 04-19-2006 01:14 PM

Replacing characters in file names?
 
Hi Folks!

First time post please bear with me. I'm using a SUSE 10.1 Beta install and a FirstClass (email) client to back up messages and attachments. The FirstClass Linux 8.090 version has a lot better export functionality in some areas than the Windows counterpart and I'm hoping to use it as a good intro to Linux for some of the Windows oriented people here. I have a problem with the way FirstClass exports and I was hoping someone might be able to help me think through the solution.

Firstclass exports email messages to RTF files. The name of the generated files contain the email address in quotes: “blipdy Blop”37.rtf for instance.

Of course when I write these to a CD and take it over to a Windows machine, the OS will not load or transfer the files because of what Windows sees as an illegal filename. I need to come up with some batch method of stripping out all of the quotes from the filenames within a directory. In some cases people will be backing up hundreds of files at a time so it can't really be done manually. My scripting skills are limited and out of date Javascript and DOS batch files. Can anyone point me in the direction of either an existing utility or a batch file tutorial that could help me do this? I've seen scripts that do global replacement within files, but nothing that renames files. Is there some obvious fix I am missing? FirstClass does not allow the ability to customize the naming conventions.

Any help would be appreciated! TIA!

Tuatha 04-19-2006 01:31 PM

if you just want to strip out quotes use something like this:

for FILE in $(ls -1 *.rtf); do
NEWFILE=$(echo $FILE | sed 's/"//g')
mv $FILE $NEWFILE
done

If that isn't quite what you want then reply & I'll fine tune it for you. SG


All times are GMT -5. The time now is 12:29 AM.