Results 1 to 1 of 1
After two days I give up. I hope someone here can help me.
Here's the project I'm working on. We are moving our storage server from an AFP capable box ...
- 02-02-2011 #1Just Joined!
- Join Date
- Feb 2011
- Posts
- 1
Remove Characters from File and Folders Recursively
After two days I give up. I hope someone here can help me.
Here's the project I'm working on. We are moving our storage server from an AFP capable box to a SMB only box. So obviously moving files that contain SMB nonoes will just scramble the files.
I need to replace: \ / * ? < > |
From all FILES and all FOLDERS on the server. The entire AFP share boils down to one folder on root so that makes it easier.
I've tried 20 different million versions of playing with various:
for i in `find . -type f`
do
echo $i
mv $i `echo $i |tr ? _`
done
The problem with this is:
1. It wont do files with spaces.
2. If a file shares the same name of the folder it's in, it fails on that file. The fix I found was to do the folders first then go through and do the files.
3. The above will only do "?", if I extend it out to do all of the characters or just replace the "?" with other characters it scrambles the file. For example, when it renames a image (.jpg), it's renamed correctly but that file is now garbage. It's no longer an image file. It's the same size at it was, but no longer readable.
This must be a pretty common issue. Moving from AFP to SMB. Can someone please help me out with something reliable that will rename my files and not DESTROY them all?
Or, worse case scenario, just strip everything but alphanumeric. At this point I would happy with even that.
Thanks to whomever can help me out!


Reply With Quote