How to Export all file names in a directory to a csv file



Below steps elaborate you how to export all the filesnames in a directory as a csv file

1. Open Notepad & copy below content & save the file in your desktop with .bat as file extension (assuming filename export.bat )

Note – observe in and out file path in the file which has to be updated with your actual folder location(in) & where while has to be exported (out).

@echo off
setlocal

set "in=C:\Users\shetty\Desktop\RehabReportMissing\"
set "out=C:\Users\shetty\Desktop\Output.csv"

if not exist "%out%" type nul>"%out%"
for /f "delims=" %%a in ('dir /b/s %in%') do (
    >>%out% echo "%%~nxa","%%a"
)


2. Now Go to desktop & Double click on the bat file you have created (in my case it is export.bat)

No comments:

Post a Comment