# Abbreviated filenames and DOS command lines

**URL:** <https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552>\
**Category:** Factual Questions\
**Created:** [September 13, 2006, 3:06pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552 "2006-09-13T15:06:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VunderBob](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@VunderBob](https://boards.straightdope.com/u/VunderBob)\
**Post date:** [September 13, 2006, 3:06pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552/1 "2006-09-13T15:06:55Z")

</div>

My DOS kung fu is getting quite rusty, unfortunately.

Is there a way to force the command line utility in Windows NT and later versions to _NOT_ truncate directory and file names with the ~1 substitution?

As an example, the directory reference C:\LONGDIRNAME becomes C:\LONGDI~1.  
This is problematic, because I’m working with 3 long names that are not unique within the first 6 characters, and I can’t change the names because of hardcoded references within various programs each contain.

My ultimate goal is a command script to perform a single function with no ability to change anything related to it’s execution, and this directory name problem causes the procedure to fail because of ‘Invalid Directory’…

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [September 13, 2006, 3:25pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552/2 "2006-09-13T15:25:28Z")

</div>

[QUOTE=VunderBob]  
Is there a way to force the command line utility in Windows NT and later versions to _NOT_ truncate directory and file names with the ~1 substitution?  
[/QUOTE]  
Can you provide a bit of context? Are you wanting to enter long names in commands, or are you wanting output (such as the result of a DIR command) to be returned in long name format, or both?

The former (making it accept long names in commands) may be achieved by enclosing the entire path in quotes, so to delete a file it would be _DEL “C:\Long Dir Name\Long File Name.ext” /[Switches]_

---

<div class="post-metadata">

**Author:** ![VunderBob](https://avatars.discourse-cdn.com/v4/letter/v/839c29/32.png) [@VunderBob](https://boards.straightdope.com/u/VunderBob)\
**Post date:** [September 13, 2006, 4:58pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552/3 "2006-09-13T16:58:29Z")

</div>

[QUOTE=Mangetout]  
Can you provide a bit of context? Are you wanting to enter long names in commands, or are you wanting output (such as the result of a DIR command) to be returned in long name format, or both?

The former (making it accept long names in commands) may be achieved by enclosing the entire path in quotes, so to delete a file it would be _DEL “C:\Long Dir Name\Long File Name.ext” /[Switches]_  
[/QUOTE]

I’m after both. I also tried the double quotes for C:&gt; cd “C:\longdirname”, and got errors regarding invalid format.

---

<div class="post-metadata">

**Author:** ![control-z](https://avatars.discourse-cdn.com/v4/letter/c/eada6e/32.png) [@control-z](https://boards.straightdope.com/u/control-z)\
**Post date:** [September 13, 2006, 5:44pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552/4 "2006-09-13T17:44:02Z")

</div>

It’s still not clear what you want to do, but in 2000 and XP “dir /x” will show you the long and short file names if that helps.

If the utility is a 16-bit DOS executable then there is no way to make them use long file names.

---

<div class="post-metadata">

**Author:** ![minor7flat5](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/minor7flat5/32/258_2.png) [@minor7flat5](https://boards.straightdope.com/u/minor7flat5)\
**Post date:** [September 13, 2006, 5:59pm UTC](https://boards.straightdope.com/t/abbreviated-filenames-and-dos-command-lines/372552/5 "2006-09-13T17:59:17Z")

</div>

When writing command scripts I have found that things get all goofed up if you pass in a short dirname one time and a long one the next, regardless of if there are quotes.

The simplest fix for that I have is to use the “~” character when referencing arguments. This strips quotes from the argument.

Example: bozo.cmd

```auto

@echo Argument 1: %~1
@echo Argument 2: %~2
@echo Argument 3: %~3

```

Now if you do this:

C\> bozo “C:\Program Files\Microsoft” C:\Program Files\Microsoft

you get this:

Argument 1: C:\Program Files\Microsoft  
Argument 2: C:\Program  
Argument 3: Files\Microsoft

This allows you to conveniently add quotes in more controlled fashion, regardless of whether or not the script caller had them.
