Jump to content
Macro Express Forums

If File Exist Command


Recommended Posts

Hi

I am a bit dumbfounded with the above command. 

The problem is if I hard code the pathname and filename the code works as expected, but if I replace it with the variable T4 with the exact same value it fails (see below)

Can anyone advise why the variable is not working?

This Example works 

image.png.a2002e5347e38b87e589331d66b693be.png

This one fails using Variable T4 (File exists in Folder)

image.png.9482c082173833d8df1668e84ff584d6.png

 

Link to comment
Share on other sites

Hi,

You've handicapped us by posting a graphic image (and that's only showing part of the macros) instead of the full code in text form. Post again with the full code (and the command text too is always helpful).

I cannot reproduce your problem. My simple test macro below displays the correct message.

Command text:

Variable Set String %tFullFilename% to "D:\Music\Artie Shaw\Big Band Years\Artie Shaw - Needlenose.mp3"
Delay: 2 seconds
If File Exists: "%tFullFilename%"
  Text Box Display: Result of IF test
Else
  Text Box Display: Result of IF test
End If

Full code:

<VARIABLE SET STRING Option="\x00" Destination="%tFullFilename%" Value="D:\\Music\\Artie Shaw\\Big Band Years\\Artie Shaw - Needlenose.mp3" NoEmbeddedVars="FALSE"/>
<DELAY Flags="\x01" Time="2"/>
<IF FILE EXISTS File="%tFullFilename%" Search_Path="FALSE"/>
<TEXT BOX DISPLAY Title="Result of IF test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 The file does exist\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<ELSE/>
<TEXT BOX DISPLAY Title="Result of IF test" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 The file does NOT exist\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<END IF/>

Are you perhaps moving the file at some point?

Terry, East Grinstead, UK

Link to comment
Share on other sites

Is it possible that you have introduced a blank space or unprintable character at the beginning or end of variable T4?  Try a TRIM of T4 (Variable Modify String:Trim) before the If File Exists command. 

Also I see you are using the Clipboard, which can sometimes have timing issues.  For debugging, put a one-second delay after each clipboard command.  I know one second is excessive, but it's just for testing at this point, to see if that clears up the problem. 

Link to comment
Share on other sites

<WINDOW ACTIVATE Title="- MediaMonkey" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<CLIPBOARD COPY/>
<DELAY Flags="\x01" Time="1"/>
<COMMENT Value="Extract the FILENAME from full path & filename."/>
<VARIABLE SET STRING Option="\x02" Destination="%Input%" NoEmbeddedVars="FALSE"/>
<VARIABLE SET INTEGER Option="\x0D" Destination="%Length%" Text_Variable="%Input%"/>
<REPEAT START Start="%Length%" Step="-1" Count="%Length%" Save="TRUE" Variable="%Index%"/>
<VARIABLE MODIFY STRING Option="\x09" Destination="%Char%" Variable="%Input%" Start="%Index%" Count="1" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%Output%" Variable="%Char%" NoEmbeddedVars="FALSE"/>
<END REPEAT/>
<VARIABLE SET INTEGER Option="\x0E" Destination="%nPosReversed%" Text_Variable="%Output%" Text="\\" Ignore_Case="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x01" Destination="%nPos%" Value1="%Length%" Value2="%nPosReversed%"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%nPos%"/>
<VARIABLE MODIFY STRING Option="\x0A" Destination="%Input%" Start="1" Count="%nPos%"/>
<TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Input%\r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \r\n\\par \\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE" _COMMENT="Disable this when satisfied."/>
<COMMENT Value="Proceed with rest of macro."/>
<OPEN FOLDER Path="C:\\Users\\desmo\\Desktop\\Music Library 2018\\Classical"/>
<VARIABLE SET STRING Option="\x00" Destination="%T4%" Value="C:\\Users\\desmo\\Desktop\\Music Library 2018\\Classical\\" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T4%" Value="%T4%%Input%" NoEmbeddedVars="FALSE"/>
<DELAY Flags="\x01" Time="1"/>
<CLIPBOARD PASTE/>
<WINDOW CLOSE Option="\x01" Title="Classical" Partial="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/>
<DATE/TIME Format="dd/MM/yyyy HH:MM" Flags="\xB0" Date="25/12/2018 22:29:25" Day_Offset="0" Month_Offset="0" Year_Offset="0" Hour_Offset="0" Minute_Offset="0" Second_Offset="0" Left="Center" Top="Center" Monitor="0" Variable="%T3%" IsDateVar="FALSE"/>
<VARIABLE SET STRING Option="\x02" Destination="%T1%" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T2%" Value="   - Moved to Classical Folder" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T1%" Value="%T1%  %T2% %T3%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x10" Destination="%T1%" NoEmbeddedVars="FALSE"/>
<IF FILE EXISTS File="%T4%" Search_Path="FALSE"/>
<CLIPBOARD APPEND TEXT Filename="C:\\Users\\desmo\\Desktop\\Music Sorting Log.txt" Prompt="FALSE"/>
<TEXT BOX DISPLAY Title="File Copied Sucessfully" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 File has been moved to \\b Classical Folder \r\n\\par \\b0\\f1\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x01" Delay="3"/>
<DELAY Flags="\x01" Time="3"/>
<ELSE/>
<TEXT BOX DISPLAY Title="File Copy Failed" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs24 The file copy \\b Failed \\b0 please check and retry\\b \r\n\\par \\b0\\f1\\fs16 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x01" Delay="3"/>
<DELAY Flags="\x01" Time="5"/>
<END IF/>
Link to comment
Share on other sites

12 minutes ago, rberq said:

Is it possible that you have introduced a blank space or unprintable character at the beginning or end of variable T4?  Try a TRIM of T4 (Variable Modify String:Trim) before the If File Exists command. 

Also I see you are using the Clipboard, which can sometimes have timing issues.  For debugging, put a one-second delay after each clipboard command.  I know one second is excessive, but it's just for testing at this point, to see if that clears up the problem. 

Hi rberq,

I tried your suggestion and it appears to be working fine now.

Thank you for your help much appreciated.

Regard

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...