用于列出长度超过255的字符的文件路径的批处理文件 [英] Batch file to list file path with character longer than 255

查看:186
本文介绍了用于列出长度超过255的字符的文件路径的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好!



我试着在这个条件下列出我的电脑和网络硬盘中的所有文件:



1.完整路径字符超过255个字符

2.输出保存在.txt文件中



如何我可以这样做吗?



仅供参考,我之前从未创建过批处理文件。在此先感谢。

Hi Guys!

I try to list all the file in my PC and network drive with this condition:

1. The full path character is exceeding 255 character
2. The output saved in a .txt file

How can I do it?

FYI, I never created a batch file before. Thanks in advance.

推荐答案

再次,我设法自己找出解决方案。但我使用批处理和vbscript文件才能使这个工作。



对于批处理文件,编写此代码并保存为[任何名称] .bat



Again, I manage to figure out the solution by myself. But I use both batch and vbscript file in order to make this work.

For batch file, write this code and save is as [any name].bat

@echo Please wait untill this window closed :P
@echo off
for /r %%a in (*) do echo %%a >> file_list.txt





对于vbscript文件,请编写此代码并保存为[任意名称] .vbs





For vbscript file, write this code and save is as [any name].vbs

Wscript.Echo "Please wait..."
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFS.OpenTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt")
Set objFS1 = objFS.CreateTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt",true)
objFS1.close
set objTextFile2 = objFS.OpenTextFile("C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt",8)
strFile = "C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt"

Do Until objTextFile.AtEndOfStream
    strLine = objTextFile.ReadLine
    If Len(strLine) > 60 Then
        strLine = Replace(strLine,"",1)
      Else
	objTextFile2.writeline strLine
    End If
   
Loop

Set objTextFile = nothing
Set objTextFile2 = nothing

objFS.copyFile "C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt", "C:\Documents and Settings\FIRDHAUS\Desktop\file_list.txt", true
objfs.DeleteFile "C:\Documents and Settings\FIRDHAUS\Desktop\file_list_temp.txt"

Set objfs = nothing
Set objfs1 = nothing
Wscript.Echo "Done :)"





注意到在vbscript中,txt文件的路径不固定。您必须根据.txt文件的位置进行更改。



将.bat文件复制并粘贴到您想要的任何根文件夹中,您将获得。带有大量文件列表的txt文件,包含完整路径:)



祝你好运!



Noted that in the vbscript, the path for txt file is not fixed. You have to change it depend on the location of your .txt file.

Copy and paste .bat file into the any root folder that you want and you will get .txt file with numerous list of files with full path :)

Good Luck!


这篇关于用于列出长度超过255的字符的文件路径的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆