![]() |
I have a file that is a remnant left behind by an iMovie project that I cannot delete. The filename has some control characters in it that prevent me from removing it.
If I do an ls in the directory where this file resides, I get: ls: 6CED D3-F485-11D8-A856-003.jpg: Invalid argument If I do ls | cat -v, I get: 6CEDM-oM-?M-?M-oM-?M-?D3-F485-11D8-A856-003.jpg If I do ls | vis, I get: 6CED\M-o\M-?\M-?\M-o\M-?\M-?D3-F485-11D8-A856-003.jpg I have tried the following things to delete the file: 1) rm -r on the parent dir => 'Invalid argument'; 2) rm -- * => 'Invalid argument' 3) boot into OS9 and delete the file => 'file not found' 4) ls -i => 'Invalid argument' Any other ideas would be greatly appreciated. Thanks, Jay |
You didn't mention this, so I have to ask:
What about renaming the file using Finder? |
And have you tried putting the filename inside double-quotes?
E.g. via filename completion - type: rm "6CED and then press the Tab key, then add the closing quote. (assuming you are using the Bash shell) |
If neither previous suggestion works, repair your hard drive's filesystem with fsck or boot to Install CD/DVD > Disk Utility > Repair Disk and try the previous suggestions again.
Trevor |
In my terminal i just did this and it worked
touch 6CEDM-oM-?M-?M-oM-?M-?D3-F485-11D8-A856-003.jpg <lyndonl@Applebeast-G4:lyndonl>$ ls 6CEDM-oM-?M-?M-oM-?M-?D3-F485-11D8-A856-003.jpg Applications Desktop ..... typed in rm -fr 6 (then hit the TAB key for auto complete rm -fr 6CEDM-oM-\?M-\?M-oM-\?M-\?D3-F485-11D8-A856-003.jpg bang file gone What shell are you using? I use bash just type in bash on the command line |
are you trying to delete the file as root permissions?
|
Thanks for the ideas. I hadn't considered the file completion idea. Alas, none of them worked.
When I do the tabbed completion, it becomes: 6CED\357\277\277\357\277\277D3-F485-11D8-A856-003.jpg but still gives "invalid argument" during execution (with and w/o quotes). I have also rebooted from another drive and run disk utility repair as well as Tech Tool repair. There is nothing to repair on this drive. I also forgot to mention in OS9 I tried the following Applescript: tell application "Finder" set name of file 1 of folder "path:to:folder" to "1234" end tell That also failed. When I try to rename the file in the finder, it will appear to be there when I open the folder and then when I single click the file, it disappears. A similar thing occurs under OS9. As far as doing it as root, that won't do any good since I am not being locked out with a permissions issue, but it is failing with an error. |
May we see the results of
ls -alo of that directory? Trevor |
have you repaired the disk with disk utility or with disk warrior or something similiar?
|
Well, let's use a rather heavy-handed approach out of the unix.wizard bag of tricks:
1. In Terminal, cd to the directory where the wicked file lives 2. Type ls -i 3. Copy the number in front of the name, in 4., I'll assume it's 6666, substitute the real number there or you'll unlink a file you never even knew by name ;) 4. Type find . -inum 6666 -exec rm {} \; 5. Done. |
It might be useful to look at that folder with the 'listdir' and 'listdir_diag' scripts that are supplied as part of this older thread on a similar problem:
http://forums.macosxhints.com/showthread.php?p=262847 Please show us the results of running those scripts to confirm that the characters in the filename are the same as those you showed above from the tab completion. It might be possible to use Perl's 'unlink' function to remove the file. (e.g. by modifying one of those scripts to add in a call to the 'unlink' function. Another possibility would be to try Apple's "File Name Encoding Repair Utility": http://www.apple.com/downloads/macos...irutility.html |
I get an 'Invalid argument' error when I type ls -i
... I have also tried deleting the file using OS9 applescript and that failed as well. |
I got and ran those two scripts mentioned. The first one failed and the second provided the following output:
birdmac:/Trash/Stills jfm$ perl listdir_diag.pl File#1 name: 6CED??????D3-F485-11D8-A856-003.jpg File#1 name has 35 characters: Hex: 36 43 45 44 ef bf bf ef bf bf 44 33 2d 46 34 38 35 2d 31 31 44 38 2d 41 38 35 36 2d 30 30 33 2e 6a 70 67 Octal: 66 103 105 104 357 277 277 357 277 277 104 63 55 106 64 70 65 55 61 61 104 70 55 101 70 65 66 55 60 60 63 56 152 160 147 |
Quote:
If that response was directed at voldenuit, -i should show you the "file's file serial number (inode number)". Perhaps you are using a different version of ls? Try /bin/ls -i Trevor |
Quote:
0xef 0xbf 0xbf 0xef 0xbf 0xbf as was shown (in decimal) when you used filename-completion. I tried to create a file with that name in a C program (using 'fopen') and it failed (errno was 22 = EINVAL = "Invalid argument"). Maybe try putting an line: unlink($filename); at the end of the loop in the 'listdir_diag' Perl script. (I'm assuming that this file is the only thing in that folder - otherwise the unlink would of course be deleting other files that you might want) And did you try Apple's "File Name Encoding Repair Utility"? (see above) |
Quote:
birdmac:/Trash/Stills jfm$ ls -alo ls: 6CED D3-F485-11D8-A856-003.jpg: Invalid argument |
Quote:
I tried the unlink thing.... it failed as I expected since I had tried a perl program and unlink before. The File Name Encoding Repair Utility gave me the following error: The file name "6CED D3-F485-11D8-A856-003.jpg" could not be repaired. -8783 I should note that the spaces do not show up as spaces, but rather as a weird symbol which looks like a black square with a white symbol in the middle that looks like a circle with a slash like you might see in a no smoking sign. |
What about using your very own neat trick:
ls -i | cat -v then go on as suggested in post #10 ? There's also an interesting article here: http://periodic-kingdom.org/ben/prog...fs_headers.php You could use the OS 9 tool Sedit recommended there to search for the exact name of the file and change it's name to something more decent at the disk-block-level. Nonetheless, it would be interesting to figure out 1. how the file was created in the first place 2. what low-level bug in OS X keeps even the most basic calls from working as expected |
Quote:
This file was created by imovie. After I finished with a project, there were some files in the trash. When I tried to empty the trash, all of the files were deleted except this one. I eventually moved the directory out of my trash so that I could have an empty trash, but I have been unable to delete the file since that time. |
Quote:
Were some of the source files for that iMovie project using filenames with non-ASCII characters? Did some of the source files for that iMovie project get imported from elsewhere (e.g. another machine)? Was file sharing involved? AFP? SMB? Is your Mac set to use some language other than US English? I'm very interested to reproduce this problem so as to be able to send a sensible bug report to Apple. Could you please email me a copy of the troublesome file (to macdev@hayne.net)? (I realize that the filename might cause problems with emailing it, and that it might not survive the email transfer to my machine, but it's worth a try.) Or maybe put this file on some publicly accessible website and tell us about it. As to the bug that is causing the various Unix utilities to fail, as I said in an older thread about a similar problem: Some gatekeeper routine that is supposed to check for valid characters is failing to do its job. Once the file is there, the various utilities are failing because they have built-in assumptions about the possible characters. Many (if not all) of the Unix utilities that have been tried invoke the 'lstat' system call to check on the file before doing their low-level operation, so it might be that the problem is just in 'lstat'. |
One more (probably hopeless) thing you could try is to use 'unlink' instead of 'rm' to remove the file.
/bin/unlink is a hard link to /bin/rm but when the program is invoked as 'unlink', a simpler path through the source code is followed (since 'unlink' is less featureful). |
Following up on my last suggestion, I wrote a C program that tries to use the 'unlink' system call to remove a file with the same name as the troublesome file of this thread. (see source code below)
When I run this program on my machine, it fails with "Invalid argument" even though there is no such file on my machine. I.e. the failure comes before the place where the file is even located. Probably not too surprising. Here's the source code: Code:
// This C program attempts to unlink (i.e. remove) a file with a specified name. |
Quote:
Quote:
Quote:
Apple will most likely deny that there is a problem in need of fixing, unless we can not only demonstrate the the file can't be deleted, but also that it is possible to create such a file. Without a realistic possibility for this to happen, they'll probably assign the bug the dreaded "not to be fixed" status. The other set of files with similar problems seen in the thread hayne quoted came from an external disk used for filesharing. Even though it was never discussed, my hunch is they may have been written by a non-OS X machine (Linux for example), but that's just a wild guess. If you have a Linux box around with FireWire and HFS+ support, you could try to put the troublesome Mac in Target mode and see if you can rm it from there. TN 1150 hints: "Non-Mac OS implementations of HFS Plus may choose to simply ignore the textEncoding field. In this case, the field must be treated as a reserved field." http://developer.apple.com/technotes/tn/tn1150.html So there is some hope encoding problems are handled in a more relaxed way by such implementations. Anyway, good luck and thanks, you brought up a very interesting problem, if that can be any consolation ;). |
| All times are GMT -5. The time now is 05:33 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.