Home > windows xp > Files with illegal filenames

Files with illegal filenames

January 1Hits:1

Possible Duplicate:
How to force Windows XP to rename a file with a special character?

I have a few files whose names have characters such as "?" and ":" that are forbidden by windows. I'm not sure how they managed to get there with these names, since I can't manually create files with these names. They're recovered from an HFS drive, but the tool that recovered them was running under windows and so should have been subject to the same restrictions while creating them, I would think.

Anyway... now that they're here, I can open them, but I can't move, copy, rename, or delete them. I want to delete a few of them, but most I want to save and copy to another drive. How might I go about this?


You cannot delete a file or a folder on an NTFS file system volume

Cause 5: The file name includes a reserved name in the Win32 name space If the file name includes a reserved name (for example, "lpt1") in the Win32 name space, you may not be able to delete the file. To resolve this issue, use a non-Win32 program to rename the file. You can use a POSIX tool or any other tool that uses the appropriate internal syntax to use the file.

Additionally, you may be able to use some built-in commands to bypass the typical Win32 reserved name checks if you use a particular syntax to specify the path of the file. For example, if you use the Del command in Windows XP, you can delete a file named "lpt1" if you specify the full path of the file by using the following special syntax:

del \\?\c:\path_to_file\lpt1

For more information about deleting files with reserved names under Windows NT and Windows 2000, click the following article number to view the article in the Microsoft Knowledge Base:

120716 How to remove files with reserved names in Windows

For more information about deleting files with reserved names under Windows XP, click the following article number to view the article in the Microsoft Knowledge Base:

315226 How to remove files with reserved names in Windows XP

If you open a handle to a file by using the typical Win32 CreateFile mechanism, certain file names are reserved for old-style DOS devices. For backward compatibility, these file names are not permitted and they cannot be created by using typical Win32 file calls. However, this issue is not a limitation of NTFS.

You may be able to use a Win32 program to bypass the typical name checks that are performed when a file is created (or deleted) by using the same technique that you use to traverse folders that are deeper than MAX_PATH. Additionally, some POSIX tools are not subject to these name checks.

Cause 6: The file name includes an invalid name in the Win32 name space You may not be able to delete a file if the file name includes an invalid name (for example, the file name has a trailing space or a trailing period or the file name is made up of a space only). To resolve this issue, use a tool that uses the appropriate internal syntax to delete the file. You can use the "\?\" syntax with some tools to operate on these files, for example:

del "\\?\c:\path_to_file_that contains a trailing space.txt "

The cause of this issue is similar to Cause 4. However, if you use typical Win32 syntax to open a file that has trailing spaces or trailing periods in its name, the trailing spaces or periods are stripped before the actual file is opened. Therefore, if you have two files in the same folder named "AFile.txt" and "AFile.txt " (note the space after the file name), if you try to open the second file by using standard Win32 calls, you open the first file instead. Similarly, if you have a file whose name is just " " (a space character) and you try to open it by using standard Win32 calls, you open the file's parent folder instead. In this situation, if you try to change security settings on these files, you either may not be able to do this or you may unexpectedly change the settings on different files. If this behavior occurs, you may think that you have permission to a file that actually has a restrictive ACL.

From my answer to a similar question:

Failsafe Method:

Boot to a Linux LiveCD. Ubuntu has good NTFS support, and Linux handles a lot more wonky-characters-in-filenames than Windows. The perl rename script may be included as the system's rename command, which is handy for batch-modifying many similarly-named files.

In Windows Command Shell with Short Filenames

The DOS command DIR/X shows short filenames, if they exist on your system.

$ cmd
c:\test> dir /x
 Volume in drive E is NUVOL
 Volume Serial Number is 80D3-A96D

 Directory of e:\tor\test

10/04/2009  05:15 AM    <DIR>                       .
10/04/2009  05:15 AM    <DIR>                       ..
10/04/2009  05:11 AM                 0 CLIP-2~1.MOV clip-2009-10-01 21;26;00.mov
               1 File(s)              0 bytes
               2 Dir(s)   5,201,670,144 bytes free

If they do exist, the REN command will move them to a new name; the new name can be a new (valid) long filename.

c:\test> ren CLIP-2~1.MOV "clip-2009-10-01_21-26-00.mov"

That's how to fix one.

To batch process all of them, you need to 1) grab the short filenames of all the files you want to move; 2) convert your listing into a batch file with the appropriate REN commands; and 3) run the resulting batch script. If you are comfortable with perl (or sed/awk, python, whatever), you can script this yourself, or you can craft it by hand from the listing you made in step 1.

But if DIR/X doesn't show the short filenames, your system has them disabled, and this solution won't help.

If Idigas' suggestion does not work, you could always move them with a Linux LiveCD such as Ubuntu. It allows question marks and colons in filenames so it should have no problem handling the files.

You just need to mount your drive first. If XP is your only operating system installed on the disk, it can probably be mounted from /dev/sda1 or /dev/hda1 depending on if it's a SCSI drive or IDE drive.

to mount a SCSI drive (if running NTFS):

mount -t ntfs-3g /dev/sda1 /mnt

to mount an IDE drive (running NTFS):

mount -t ntfs-3f /dev/hda1 /mnt

If it's a FAT32 volume, you can use vfat as the type (-t vfat)

Try Delete Doctor (freeware) or delinvfiles (shareware, but have more features) to delete the file with its short or UNC name

I've used Windows Services for Unix to remove these sorts of files in the past.

The reason that such files can be created is that Windows has support for POSIX, so NTFS was designed to be able to support all the features of POSIX filesystems. However, normal Win32/Win64 programs, which are using the regular Windows API, can't access these features. You need to use a program written to the native API or the POSIX api to create or remove such files.

For some reason, I usually have more luck when moving/copying/renaming/(anything really) files from the command line, than when doing it windows explorer.

Related Articles

  • Files with illegal filenames January 1

    Possible Duplicate: How to force Windows XP to rename a file with a special character? I have a few files whose names have characters such as "?" and ":" that are forbidden by windows. I'm not sure how they managed to get there with th

  • Accessing file with illegal character in WindowsNovember 14

    I have a setup with an Apple Time Capsule that I'm trying to access from a Windows computer I installed Airport on. I can connect fine and everything works fine, until I try to access a folder with an asterisk in it (*) and then Windows will complain

  • Can't copy file with green filename, access denied

    Can't copy file with green filename, access deniedNovember 5

    Using Windows Explorer under XP I see some of my files have green filenames. When I try and copy one of these files I get an error reporting Access denied. The My pictures folder also appears with green text and I have a large number of photos from f

  • Re-uploading file with unicode filename creates identical duplicateJanuary 27

    I'm running a Django site on a Debian 6 system, with a gunicorn server and nginx 0.7.67 handling static files. The filesystem locale is set to sv_SE.UTF-8. I got a problem where another user uploaded a file with a filename containing unicode characte

  • Clearing the file by cat filenameJuly 25

    The files may be cleared using cat /dev/null > filename. Is it the same special file that is working whenever cat > filename is done? --------------Solutions------------- No, what is clearing the file is not /dev/null, but the > redirection, whic

  • Renaming hidden files to their filename sans .. (double dot)August 17

    I accidentally ran a script that added a ".." infront of a variety of files. ie. originalfile ==> ..originalfile Now I have a variety of files that are hidden. Being new to Linux commands, is there a script that can reverse the above? Searchi

  • Perl replace string inside file with the filename?December 18

    I need to replace a string in a JSON file with the filename of that file. I successfully matched the string to be replaced using the regex below, but I can't figure out how to get the filename in there to replace the string with. Note: This is a scri

  • Why does Netbeans navigator pane not populate javascript files with specific filenames?January 17

    While I admit this is a pretty obscure problem, I'm posting this partly in case it is driving others crazy (too), partly because it might have wider ramifications, and partly because it may be an issue with my project settings. In NB-8.1 I have sever

  • imagemagick resize - multiple files with wrong filenames after resizing .jpg imagesJanuary 23

    imagemagick resize - multiple files with wrong filenames after resizing .jpg images Ubuntu 14.04 and ImageMagick 6.7.7-10 I need to resize ~900 jpg images (kept in several folders) to several dimensions, with the current aspect ratio. I wished to sta

  • Copy files with changing filenameFebruary 5

    I'm trying to copy several files with changing filenames. It seems very easy but I can't seem to work out how to do it without actually listing out the filenames in their entirety. The first few letters of the filenames correspond to the subject name

  • Renaming uploaded files - removing illegal charactersApril 23

    I must admit that I am totally unexperienced with developing anything to SP, but my problem sounds pretty simple - I need to manage some kind of regex command to rename any files uploaded to SP. The situation is - user uploading filename containing i

  • Need to attach file with illegal character - using shortcuts as workaround?June 10

    Let me preface this by saying that I don't know too much about SharePoint right now. I need to attach files to various list items. Each file that needs attaching is in a different folder and they all contain the "&" character. To save space

  • Rename files to empty filename in Windows (Vista)June 9

    Vista allows files with empty "first name" (for example, ".svn"). However, when I try to remove the filename of an existing file, leaving the prefix, in Explorer or using cmd's 'rename', I fail. How can I easily rename files to include

  • Uploading files with similar filename in Amazon S3May 25

    Basically, how does Amazon S3 handle files which already have the same filename inside a specified bucket? Assuming I can only upload to one particular bucket, will S3 change the filename or something? Thanks! --------------Solutions------------- No,

  • Command line: create file with new filename if the filename already existsAugust 2

    I was wondering if it was possible have a command that creates one file, but every time the command is executed, it wouldn't overwrite the file created in the previous execution. For example: touch test1.txt would create 1 file called test1.txt. But

  • How to annotate files - when long filenames are not enoughAugust 28

    I work with many files doing general data analysis. Things I want to know about my files include: what data is contained in the file (in long and very long descriptive, english text)? is the file downloaded from somewhere (where? when?) or generated

  • Windows batch file: rename files (possibly in multiple folders) based on input file (of target filenames)October 6

    I am a Batch-newbie... This "tool" is to automate the slimming down of Windows (XP) by disabling certain system driver, DLL and EXE files. Instead of outright deletion, I wish to rename-in-place, thus "removing" them from the OS, but n

  • Bash Script: Redirecting to file gives "Illegal Instruction"October 18

    I'm trying to use a bash script for a study assignment. As a bash noob, I tried to adapt an existing one to suit my purpose: Compile/Make a C-program with different compile arguments, execute it and redirect its output to a file. The script is as fol

  • How to Save a File with a Filename Using a TimeCode in LinuxNovember 18

    I'm on a tablet pc (Lenovo X60) so my keyboard is not available all (most) of the time, AND I'm trying out Linux Mint instead of Windows. The main thing I'm missing is my AutoHotKey :( I need to figure out how to give a filename a timecode of year-mo

  • How to have a webpage File Save As filename different from the page URL?January 17

    For example - see this BBC News Page: http://www.bbc.co.uk/news/entertainment-arts-16578905 Now Save the page as a web page - notice how the actual filename of the file saved ( BBC News - Golden Globes Ricky Gervais 'subdued', say critics.htm ) is di

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.764 s.