[UPDATE] - Added a batch script I was trying to use below.
I'm very new to batch scripting - I have some python and VBA experience, but batching is new to me
I'm trying to use a list of employee names from a termination list and search the files within a folder that contains the application lists of all the company's apps. This way if the employee appears on a user list, we know which app we must remove them from.
For example:
Termination List.txt - The list of employee names. With each name on a new line:
Ex:
John Doe
Jane Smith
etc
Folder containing all the Application user lists: "C:\Desktop\Application Userlists"
The user lists are in various formats: App1.xlsx, App2.csv, App3.pdf
The output file I'm aiming for:
TerminationScanner.xlsx or TerminationScanner.txt, etc - The file would show which employees appear on which lists:
App1.xlsx: John Doe, Jane Smith
App2.csv: Jane Smith
App3.pdf: Jon Doe
I've been trying to look at various websites and forums, as well as some questions here in Stack Overflow to try and understand it, but couldn't quite piece them together to make this. :/
Any help would be greatly appreciated! And if you can help me, if you could also explain how it would work I'd appreciate it even more as I do want to learn!
Below is the code I was trying to use:
Code: Select all
@ECHO OFF
@ECHO OFF
SETLOCAL
SET "sourcedir=\\FS01.winmain.local\main\InternalAudit\3. SOX\SOX 2021\2021 ITGC SOX\2. Final Fieldwork\Year-End Testing\YE.ITGC.04 - New Hires\Evidence\Application Userlists\Application Userlists - Year End"
rem Source directory of application files
SET "destdir=C:\Users\tpiccirillo\Desktop\Termination Scanner Output files"
rem Destination directory where report will go
for /f "delims=" %%a in ('dir /s /b "%sourcedir%\*.*"') do (
echo(===== file %%~nxa ===== FINDSTR /N /g:"C:\Users\tpiccirillo\Documents\Senior IT Auditor\2022 Goals\Termination Scanner Process\Batch Script Version\searchlist.txt" "%%~fa") >> "%destdir%\results.csv"
rem pnxa = path name and extension
GOTO :EOF
But it appears to just list the different files in that source directory without matching and stating which employee names it found. I know for a fact that not all the files have names that match. I'm not sure exactly what I'm doing wrong.
Below is what appears for each file in that source directory:
===== file Evidence\Application Userlists\Application Userlists - Year End\ActiveEmpGroupMembership-Report -01-31-2022.csv ===== FINDSTR /N /g:"C:\Batch Script Version\searchlist.txt" "C:\Evidence\Application Userlists\Application Userlists - Year End\ActiveEmpGroupMembership-Report -01-31-2022.csv"