Opening Filenames with Colon (":") in Windows 7

How to get a file in Windows with a colon in the filename?

I found a very similar character to a colon, "꞉" it is a unicode character called a Modifier Letter Colon. This has no space like the fullwidth colon and is pretty much exactly the same as a regular colon but the symbol works. You can either copy and paste it from above or you can use the code point, U+A789

Make filename with colon (“:”) in Windows

Colon is not an allowed character in a filename in Windows. Or, more precisely, it is used to address an Alternate Data Stream of a file. So, asdf:qwer addresses the stream named qwer of the file named asdf.

This is very similar to the backslash. asdf\qwer is also not a valid filename, instead it addresses the file qwer of the folder asdf.

how do I clone files with colons in the filename

If you try doing:

touch "styles-ie (1:12:11 6:02 PM).css"

you will see that you cannot create it on Windows.

Basically, the repo has the file ( the blob and the tree entry ) but you cannot checkout on Windows as git would be unable to create such a file. No other way but to change the filename.

Colon in file names in Python

Windows NTFS supports file "stream". You basically append data to a file, outside of the file, and can't be viewed normally. When you created the file "word1:word2", the hidden stream "word2" is attached to "word1". If you copied the file word1 to another NTFS machine, the word2 data would come with you

Go here http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx and download the streams program. Running it will show you that word2 is a stream attached to word1

This page also talks about streams:
http://www.forensicfocus.com/dissecting-ntfs-hidden-streams

To really prove this easily, you can use Notepad but you need to use the .txt extension:

 file=open('word1.txt:word2.txt','w')
file.write('Testing streams')
file.close()

Now, using the cmd program, change directories to where you created the files. Type the following:

 c:\tmp> notepad word1.txt

You will see an empty file. Now, try this:

 c:\tmp> notepad word1.txt:word2.txt

You should see the text Testing streams.

Colon in a git file name. Windows developers alarm?

You could install some git hooks (doing appropriate checks), notably a git precommit hook (at least for Linux users), or a prepush hook.

Of course, that requires some cooperation (and convincing people to use it).

Is there a work around for : (colon) when downloading from ftp using windows

[Untried]

get remotefilename localfilename

is apparently valid, so placing a valid windows filename as a second argument should d/l to the file specified.

[Addendum - also untried]

(after Echo lcd folder>>first.dat)

echo mls remotefilesrequired awindowlistfilename>>first.dat
rem this should log in and create awindowslistfilename
rem containing the remote filelist
ftp -v -i -s:first.dat
del second.dat 2>nul
setlocal enabledelayedexpansion
for /f "delims=" %%a in (awindowslistfilename) do (
set "remote=%%a"
echo get !remote! !remote::=.!>>second.dat
)
endlocal
Echo bye>>second.dat
ftp -v -i -s:second.dat
del first.dat
del second.dat

Since I'm not aware of the return format for mls, I'm assuming that it's a simple file-list, one to a line.

This code first executes the ftp log-on palaver and an mls command, creating awindowslistfile locally.

It then deletes second.dat (the 2>nul suppresses error messages like file not found appearing on stderr)

setlocal enabledelayedexpansion and endlocal bracket a mode where the syntax changes such that !var! may be used to access the run-time value of a variable, whereas %var% always refers to the parse-time value.

The for/f command reads the filename (parenthesised) and assigns each line in turn to the metavariable %%a. The delims= option ensures that the entire line is assigned, ignoring the normal tokenising procedure.

A series of individual get commands is then written to second.dat, with the substitution of : by . in the name.

Finally, add the bye and FTP again.

(I'm not sure whether first.dat will also require a bye and second.bat will need to prelimnary commands, but could be...)

Note that it's batch convention to enclose filenames that may contain separators like Space,; in "quotes". How FTP will feel about that, if necessary, I can only guess.

Naturally, extra lines within the loop

 set "remote=!remote:x=y!"

could be used to serially replace character sequences x by y if there are any other problematic characters encountered.



Related Topics



Leave a reply



Submit