• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to run a job that will check if files exist?

Community Beginner ,
May 02, 2016 May 02, 2016

Copy link to clipboard

Copied

I have a folder 'realtime' that has about 15 txt files(test1.txt,other.txt etc), theres is other jobs nothing related to coldfusion that if something goes down then the file wont exist anymore.

So I want to create a job that if a txt file doesnt exist then it will sent me a email.

what would be the best way to do something like this?

would i have to check for each individual txt file , something like ??

<cfset Pathtest = "\\folder1\dept\Alerts\other.txt">

<cfif !fileExists(Pathtest)>

  <cfmail ...>

  sent me a email

  </cfmail>

   

</cfif>

Views

417

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 03, 2016 May 03, 2016

If all the files are in the same directory, you can create a comma-delimited list (or even an array) of the filenames and loop through that.

<cfset fileList = "test1.txt,other.txt,test999.txt" />

<cfloop list="#fileList#" index="idx">

    <cfif NOT FileExists('\path\to\files\#idx#')>

        ... email me ...

    </cfif>

</cfloop>

HTH,

^_^

Votes

Translate

Translate
LEGEND ,
May 03, 2016 May 03, 2016

Copy link to clipboard

Copied

If all the files are in the same directory, you can create a comma-delimited list (or even an array) of the filenames and loop through that.

<cfset fileList = "test1.txt,other.txt,test999.txt" />

<cfloop list="#fileList#" index="idx">

    <cfif NOT FileExists('\path\to\files\#idx#')>

        ... email me ...

    </cfif>

</cfloop>

HTH,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

LATEST

Thank you for marking my answer correct.

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation