View Full Version : Script to remove characters
cjnkns
February 4th, 2010, 02:34 AM
I have a music collection I need to be able to share between Linux and Windows.
When I rip cd's on Linux it did so with characters that Windows doesn't like.
So I have directories and mp3 files with I can't run/open on Windows.
Does anyone know of a script that I can use that would go through my Music collection and clean (Remove) those characters that Windows doesn't' allow so I can move the collection to either OS?
Thanks a million! :)
kaibob
February 4th, 2010, 05:26 AM
I have a music collection I need to be able to share between Linux and Windows.
When I rip cd's on Linux it did so with characters that Windows doesn't like.
So I have directories and mp3 files with I can't run/open on Windows.
Does anyone know of a script that I can use that would go through my Music collection and clean (Remove) those characters that Windows doesn't' allow so I can move the collection to either OS?
Thanks a million! :)
The following command will remove the specified characters from all file names in the /target/directory and subdirectories. You have to change ;?|\\ to the characters you want to remove. The -n option does a dry run and reports proposed changes. Substitute -v for -n to actually rename the files. As always, be sure to have a backup copy of the files.
find /target/directory -iname "*.mp3" -type f | rename -n 's/[;?|\\]//g'
Renaming directories can be difficult if they are nested more than one level deep, but the following command should work. The 5 can be changed to the levels of subdirectories or just leave it as it is. Ignore messages concerning STDIN.
for i in {1..5} ; do find /target/directory -maxdepth $i -type d | rename -v 's/[,.;:\\]//g' ; done
cjnkns
February 4th, 2010, 12:09 PM
Thanks I'll give it a shot!
I appreciate it.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.