Question : Folder Contents

Hi,
In the previous question I got a script to move files into folders batched 100 per folder.
Now I'm having the problem of finding the files I'm looking for.
Is it possible to make some sort of list, perhaps a csv, that contains the folder name and the name of first and last file in that folder?
Kind of like the words at the top left and right of a dictionary page.
Thanks
Steven

Answer : Folder Contents

This should do it.  As before, customize the value of the folder variable.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
@echo off
setlocal enabledelayedexpansion
 
set folder=c:\pdfs
set log=index.csv
 
echo Folder,First File,Last File > "%log%"
 
for /F "tokens=*" %%G in ('dir "%folder%" /A:D /B /O:N') do (
 set filecount=0
 for /F "tokens=*" %%H in ('dir "%folder%\%%G" /A:-D /B /O:N') do (
  set /A filecount+=1
  if [!filecount!]==[1] set first=%%H
  set last=%%H
 )
 echo %%G,!first!,!last! >> "%log%"
)
Open in New Window Select All
Random Solutions  
 
programming4us programming4us