• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 125
  • Last Modified:

Scripting question

Hello All,

I just want to say off the bat that I am new to the Level Platform systems, and also very new to attempting scripts. I have been tasked to see if it is possible to set up a script for LP that would also trigger an alert to let us know when a file was found in a directory.

Here is the situation:
I would like to design the script to search a directory for a specific file ext, which is .spi.
Inside this directory, there are quite a few .spi files, but some have CD in the file name which we do not care to see in our results.
Once the script has locates the new .spi file that was created from a back up we would like it to trigger an alert for us to see.

What I have so far (its not much). After many google searches I came accross the below script and just through my information into it to see if I could get it to work. Which it does. It finds the file and generates the report to my desktop. It finds the 2 .spi files I have put there. The problem is, one of those has "CD" in it, and that is what I would like to exclude. The end result would be to have the report really be an alert in LP.
(for /R "c:\users\kbosse\desktop" %%F in ("*.spi") do echo %%~fF,%%~zF)>c:\users\kbosse\desktop\report.csv

I have read a little bit about 'grep' but from my understanding that's not really a windows thing?

I would like to think I'm on the right path, but with my lack of experience of scripting, I'm trying to learn on the fly.
Does any of this sound possible?

1 Solution
Try this script :

@echo off
@setlocal enableextensions enabledelayedexpansion

set thepath="c:\users\kbosse\desktop"
set stringtoexclude="CD"
set fileredirec="c:\users\kbosse\desktop\report.csv"

for /R %thepath% %%F in ("*.spi") do (
set thefile=%%F

echo !thefile! | findstr /C:%stringtoexclude% 1>nul
if errorlevel 1 (
      echo %%~fF,%%~zF
) > %fileredirec%
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now