Need to rename files and folders with invalid characters in the names
Hi All,
I have 1.6GB of files in a folder on a Linux server that I need to copy to a Windows 2003 server. The problem is that all the files and sub folder names have 2 colons (::) in them. Is there a script or command way to rename all these files and folders to replace the colons with a space or dash so I can copy them without the dreaded "Invalid filename" errors? Here is a capture of some of the files/folders: -rwxr-xr-x 1 root root 20480 Apr 1 09:18 1141761865::Inforequest.doc drwxr-xr-x 2 root root 48 Apr 1 09:18 1143511838::temp drwxr-xr-x 2 root root 96 Apr 1 09:18 1143728379::Proposal -rwxr-xr-x 1 root root 1071616 Apr 1 09:18 1144183601::Vantage1.doc Any help would be greatly appreciated. Thanks Ray Laureyns |
man rename
rename should work for you. just changing what the example is to fit your situation should work. |
Ok, maybe I'm missing something here.
Quote:
Well, maybe I wasn not clear. I have thousads of files and folders that I need to rename in this folder. So simply usning rename I have not found a syntax that can do all the files and folder recursivly. I have seen some examples of using tr to truncate the files but I don't want to corrupt them. Any other ideas? Thanks Ray Laureyns |
Maybe something like this old kludge of mine? Modify to suite your needs ...
Code:
#!/bin/bash first, with increasing depth; then repeat with files. find -type d -maxdepth 1 -exec savedscript "{}" \; find -type d -mindepth 1 -maxdepth 2 -exec savedscript "{}" \; find -type d -mindepth 2 -maxdepth 3 -exec savedscript "{}" \; ... find -type f -exec savedscript "{}" \; Cheers, Tink |
how are you ls those files? what are the options that you are using?
|
huh?
|
All times are GMT -5. The time now is 10:41 PM. |