Computing.Net > Forums > Programming > Long filenames not supported proble

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Long filenames not supported proble

Reply to Message Icon

Name: ron5001
Date: July 18, 2005 at 08:01:22 Pacific
OS: XPSP2
CPU/Ram: P4 3000 1024
Comment:

I am running batch files from WinXP SP1, and when I export a list of folders to a text file, they are exported with long folder and file names that CANNOT be read back into my FOR loop.

e.g. Batch file produces a text document containing lines like this:

c:\Test\Somechappy\Application Data
c:\Test\Somedude\Application Data
c:\Test\Somebloke\Folder\Application Data
c:\Test\Someguy\Temp Folder\Application Data

but attempting to use the text file in a FOR loop results in a "File not found" error because none of my batch files can handle files/folders of more than 8 characters.

To make the batch file work you have to replace a lot of the text.

c:\Test\Somech~1\Applic~1
c:\Test\Somedude\Applic~1
c:\Test\Somebl~1\Folder\Applic~1
c:\Test\Someguy\TempFo~1\Applic~1

Can I get my batch files to recognise long folders and filenames? Otherwise I need to change the line that creates the text file somehow :

DIR /S /B /AD c:\Test\\Applic~1*.* > LIST.txt

or do some horrendous "replace text within file" command using wildcards that I don't even know are supported.

Um....help

Dan The Man



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: July 18, 2005 at 08:37:52 Pacific
Reply:

Can you post the BAT?

Not obvious what's "not working".

M2


If at first you don't succeed, you're about average.


0

Response Number 2
Name: StuartS
Date: July 18, 2005 at 11:28:53 Pacific
Reply:

Another thing comes to mind. If you are doing something that applies to all registered users on a computer, why not use All User user name. Thats what it is there for.

You may also find thats its not the LFNs that are causing you problems, but spaces within the file name. One way round that is to enclose the entire path name inside double quotes.

Stuart


0

Response Number 3
Name: ron5001
Date: July 19, 2005 at 03:32:07 Pacific
Reply:

This line exports the paths of all "Application Data" folders to a text file called List.txt

REM DIR /AD /S /B c:\Test\Applic~1*.* > List.txt

I had to change "Application Data" to "Applic~1" before it would work. The text file ends up looking like this:

c:\Test\Somechappy\Application Data
c:\Test\Somedude\Application Data
c:\Test\Somebloke\Folder\Application Data
c:\Test\Someguy\Temp Folder\Application Data

Back in the batch file, this line then reads from that text file and deletes the contents of each folder.

FOR /F %%a IN (List.txt) DO DELTREE /Y %%a\*.*

But it doesn't work because the directories are exported with long filenames. The only way I have got it to work is to replace lines in the text file:

c:\Test\Somechappy\Application Data
replaced by:
c:\Test\Somech~1\Applic~1

then it works, so it is definitely to do with the path, you can display short paths with DIR with the /B switch but it doesn't write short paths to the text file.

The allusers approach is a good idea but won't work for me because a)I'm deleting files not supplying them b)I'm going to use this batch file on a network location.
Thanks though.

Any thoughts?

Dan The Man


0

Response Number 4
Name: ron5001
Date: July 19, 2005 at 04:34:12 Pacific
Reply:

"Subject: Long filenames not supported proble"

Ah! What exquisite irony!

Actually I'm fairly sure I just missed the m

Dan The Man


0

Response Number 5
Name: Mechanix2Go
Date: July 19, 2005 at 05:13:19 Pacific
Reply:

Hi Dan,

Try this:

::==
dir /ad /b /s "some long" > list.txt
for /f "tokens=*" %%L in (list.txt) do deltree /y "%%L"
::==

M2


If at first you don't succeed, you're about average.


0

Related Posts

See More



Response Number 6
Name: ron5001
Date: July 19, 2005 at 07:34:28 Pacific
Reply:

That did the trick! Thanks, now to figure out what that line's all about.....

Dan The Man


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Long filenames not supported proble

regsvr32 failure in XP (but okay in 98) www.computing.net/answers/programming/regsvr32-failure-in-xp-but-okay-in-98/2814.html

Rename/Shorten long filenames www.computing.net/answers/programming/renameshorten-long-filenames/7613.html

Long to Short Filename www.computing.net/answers/programming/long-to-short-filename/9660.html