0

I have a simple batch which saves the content of a specific folder and its subfolders to a text file.

Here's the original command. It is used on a Windows 7 environment.

dir I:\Logistics\Hermes\1445\LIN\ /a /s /b > C:\out\LIST.txt

Problem: It creates the file and also lists most of the folders and files, BUT not all of them.

Here's an extract of the LIST.txt file. The first 4 rows are missing the pdf file in the folder.

I:\Logistics\Hermes\1445\LIN\557487
I:\Logistics\Hermes\1445\LIN\557488
I:\Logistics\Hermes\1445\LIN\557489    
I:\Logistics\Hermes\1445\LIN\557669
I:\Logistics\Hermes\1445\LIN\552371\XXXX_641428_20141022_1604.zip
I:\Logistics\Hermes\1445\LIN\552372\XXXX_859038_20141022_1604.zip    
I:\Logistics\Hermes\1445\LIN\552379\Overview
I:\Logistics\Hermes\1445\LIN\552379\Overview\manuals_overview_1445_LIN.pdf    
I:\Logistics\Hermes\1445\LIN\552381\LTBJ_886469_20141022_1800.zip

I can't figure out why. There are no filters, and other pdfs are listed. The files are not read-only. The user has full read/write permission on these directories.

Is it because the folder names are only numbers ?

I appreciate any help on this batch thing. Thank you !

Magoo
  • 77,302
  • 8
  • 62
  • 84
chrimens
  • 23
  • 9
  • I believe you need to be more explicit. Are you saying that the directories `...557487` etc contain .pdf files which are not being listed? What do you want? Just a listing of the `.pdf` files, or all files, or what? Nominally, the `/a` switch should be followed by a further qualifier. Without knowing what your target list is, we're guessing. Perhaps `attrib /s I:\Logistics\Hermes\1445\LIN\*` may reveal something? – Magoo Oct 31 '14 at 12:34
  • Thanks Magoo. Yes, in each of the folders there's 1 pdf file. Just like the rows below where the other pdf or the zip files are listed. The batch simply ignores the content of the numbered folders. I double checked again to see if the pdfs are really there, and they are. – chrimens Oct 31 '14 at 17:02
  • All I can say is that it works fine for me. I created numbered subdirectories in my test area and tested with empty directories and directories with files in them. I used `/a` and omitted `/a`. All worked quite happily. I can only suggest a typo while searching your `list.txt` file with your text-editor. – Magoo Oct 31 '14 at 17:28

3 Answers3

0

You command includes directory names so you see I:\Logistics\Hermes\1445\LIN\557487 as its a directory.

To exclude add: /a-d

(Attribute-not-Directory)

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • Thanks Alex! The path name needs to be included. I nevertheless tried it and it just ignores the folders (does not list the pdf files). – chrimens Oct 31 '14 at 17:11
0

The bahaviour of dir /s /b command is to enumerate each level complete, so, in your case, the contents of I:\Logistics\Hermes\1445\LIN are listed. When this folder is completly enumerated, it starts to enumerate the contents of each of the subfolders, so, the contents of 552371 are enumerated before the contents of 557487 (in NTFS drives the elements are name ordered). Your missing pdf files will be some lines below, when the 557487 folder is reached.

MC ND
  • 69,615
  • 8
  • 84
  • 126
  • Thanks MC ND, good point, I learned something! I now did a search on the whole txt file (has 4900 rows) and did not find the folder name again. So the problem lies elsewhere. – chrimens Oct 31 '14 at 17:09
0

OK, thanks to MC ND's hint I finally found out that it's a memory issue. About 80000 files in 12000 folders is simply too much for dir. The saved text file simply stops randomly after about 5000 rows. Finally I split up the whole directory into subfolders.

chrimens
  • 23
  • 9
  • Does the issue manifest itself only when you are redirecting the output to a file? – Andriy M Nov 18 '14 at 16:40
  • Tried it, and: yes. Could the txt file itself be the problem? – chrimens Nov 19 '14 at 07:54
  • No idea. I tried reproducing a similar scenario on my machine: created 100,000 files, put them into 10,000 directories, then listed them all with a single `DIR /S /B` into a file – no issues. The output file's size was over 2.5 MB. – Andriy M Nov 19 '14 at 13:51