Windows XP Community - XPHeads



Spyware Doctor

Shell - Get short file names for environment variable

microsoft.public.windowsxp.general


Reply
  #1 (permalink)  
Old 01-24-2008, 02:58 PM
Markus Eßmayr
 
Posts: n/a
Shell - Get short file names for environment variable
Hello,

I have a batch file something like that:

@echo off
set SOMEIMPORTANTFILE=C:\Program Files\Some Directory With Spaces\file.dat
app1.exe "%SOMEIMPORTANTFILE%"
app2.exe "%SOMEIMPORTANTFILE%"
app3.exe "%SOMEIMPORTANTFILE%"

Now I also should add to call another application, which in no case supports
spaces in file names.

Is there a way similar to using %~s1 for converting %1 to a short file name?

Thanks!
Max


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-24-2008, 03:17 PM
Pegasus \(MVP\)
 
Posts: n/a
Re: Shell - Get short file names for environment variable

"Markus Eßmayr" <essmayr/at/racon-linz.at> wrote in message
news:el4kPmpXIHA.4880@TK2MSFTNGP03.phx.gbl...
> Hello,
>
> I have a batch file something like that:
>
> @echo off
> set SOMEIMPORTANTFILE=C:\Program Files\Some Directory With Spaces\file.dat
> app1.exe "%SOMEIMPORTANTFILE%"
> app2.exe "%SOMEIMPORTANTFILE%"
> app3.exe "%SOMEIMPORTANTFILE%"
>
> Now I also should add to call another application, which in no case
> supports spaces in file names.
>
> Is there a way similar to using %~s1 for converting %1 to a short file
> name?
>
> Thanks!
> Max
>


You could use this little batch file:
@echo off
set SomeImportantFolder=c:\Program Files\Microsoft Office
pushd "%SomeImportantFolder%"
echo Q > "%temp%\debug.scr%"
debug < "%temp%\debug.scr%" > nul
set wd=%cd%
echo The 8.3 path is %wd%
popd


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-24-2008, 03:32 PM
Markus Eßmayr
 
Posts: n/a
Re: Shell - Get short file names for environment variable
Thanks very much for you fast answer!
Could you please explain, what you are doing here?

Thanks!


"Pegasus (MVP)" <I.can@fly.com.oz> schrieb im Newsbeitrag
news:u%23DYLxpXIHA.5132@TK2MSFTNGP02.phx.gbl...
>
> "Markus Eßmayr" <essmayr/at/racon-linz.at> wrote in message
> news:el4kPmpXIHA.4880@TK2MSFTNGP03.phx.gbl...
>> Hello,
>>
>> I have a batch file something like that:
>>
>> @echo off
>> set SOMEIMPORTANTFILE=C:\Program Files\Some Directory With
>> Spaces\file.dat
>> app1.exe "%SOMEIMPORTANTFILE%"
>> app2.exe "%SOMEIMPORTANTFILE%"
>> app3.exe "%SOMEIMPORTANTFILE%"
>>
>> Now I also should add to call another application, which in no case
>> supports spaces in file names.
>>
>> Is there a way similar to using %~s1 for converting %1 to a short file
>> name?
>>
>> Thanks!
>> Max
>>

>
> You could use this little batch file:
> @echo off
> set SomeImportantFolder=c:\Program Files\Microsoft Office
> pushd "%SomeImportantFolder%"
> echo Q > "%temp%\debug.scr%"
> debug < "%temp%\debug.scr%" > nul
> set wd=%cd%
> echo The 8.3 path is %wd%
> popd
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-24-2008, 03:41 PM
Pegasus \(MVP\)
 
Posts: n/a
Re: Shell - Get short file names for environment variable
I thought you might ask . . .

*** pushd "%SomeImportantFolder%"
This is a combined drive & directory change command
that remembers to original drive & directory.

*** echo Q > "%temp%\debug.scr%"
This writes the letter Q (for Quit) into a script file which
I will use in the next command.

*** debug < "%temp%\debug.scr%" > nul
This launches debug.exe for a very brief session. The
sneaky part is that debug.exe is in essence a 16-bit
program. When you launch a 16-bit program then
your current folder name reverts to the 8.3 format.
Any 16-bit application will do.

*** set wd=%cd%
This picks up the current folder name which is now in
8.3 format.

*** popd
This returns you to the original folder.


"Markus Eßmayr" <essmayr/at/racon-linz.at> wrote in message
news:%23Z9AO5pXIHA.1204@TK2MSFTNGP03.phx.gbl...
> Thanks very much for you fast answer!
> Could you please explain, what you are doing here?
>
> Thanks!
>
>
> "Pegasus (MVP)" <I.can@fly.com.oz> schrieb im Newsbeitrag
> news:u%23DYLxpXIHA.5132@TK2MSFTNGP02.phx.gbl...
>>
>> "Markus Eßmayr" <essmayr/at/racon-linz.at> wrote in message
>> news:el4kPmpXIHA.4880@TK2MSFTNGP03.phx.gbl...
>>> Hello,
>>>
>>> I have a batch file something like that:
>>>
>>> @echo off
>>> set SOMEIMPORTANTFILE=C:\Program Files\Some Directory With
>>> Spaces\file.dat
>>> app1.exe "%SOMEIMPORTANTFILE%"
>>> app2.exe "%SOMEIMPORTANTFILE%"
>>> app3.exe "%SOMEIMPORTANTFILE%"
>>>
>>> Now I also should add to call another application, which in no case
>>> supports spaces in file names.
>>>
>>> Is there a way similar to using %~s1 for converting %1 to a short file
>>> name?
>>>
>>> Thanks!
>>> Max
>>>

>>
>> You could use this little batch file:
>> @echo off
>> set SomeImportantFolder=c:\Program Files\Microsoft Office
>> pushd "%SomeImportantFolder%"
>> echo Q > "%temp%\debug.scr%"
>> debug < "%temp%\debug.scr%" > nul
>> set wd=%cd%
>> echo The 8.3 path is %wd%
>> popd
>>

>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:19 AM.


Registry Mechanic - Free Scan Now
Driver Scanner 2009 - Free Scan Now




Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74