开发者

list contents with batch

开发者 https://www.devze.com 2023-02-17 22:52 出处:网络
I need a bat file that will list the entire contents of a folder Including its subfolders in a text file.开发者_运维技巧

I need a bat file that will list the entire contents of a folder Including its subfolders in a text file.开发者_运维技巧

one of our programs seams to constantly be missing or adding files. a list would help me trackdown the issue(s).


Wouldn't this do it?

dir C:\autocad /s /b > output.txt


If you have PowerShell, you can use this instead:

cd *<targetdirectory>*
ls -r |% { $_.FullName } | Set-Content foldercontents.txt

I only bring it up, because you can then compare the next time you check to see differences:

$original = Get-Content foldercontents.txt;
$now = ls -r |% { $_.FullName }
Write-Host "Missing Files:";
$original |? { -not $($now -contains $_) };
Write-Host "Added Files:";
$now |? { -not $($original -contains $_) };


If your problem is just tracking down what is the program that is creating and removing files, you may monitor all the file accesses in the system with Sysinternals Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 . An easy way to watch all the file accesses being done by any process.

0

精彩评论

暂无评论...
验证码 换一张
取 消