Jump to content

Array Question


Recommended Posts

Hi everyone,

I've split this off from the other thread I made (http://www.autoitscript.com/forum/index.php?showtopic=72579), because it relates specifically to working with an Array. I have the following code:

#Include <File.au3>; Include "File Management" User Defined Functions (UDF).
#Include <Array.au3>; Include "Array Management" User Defined Functions (UDF).

Global $exiftoolPath = "C:\Temp\MODI Images\"; Set variable for path to exiftool.exe.

$FilePath = InputBox ( "Path to Image Files", "Please enter the path to the image files you wish exiftool to operate on. The default path has been entered for you. Overwrite this if this is not correct. To confirm, click Ok or press Enter.", "C:\Temp\MODI Images\", "", 300, 200 ); Request user enter path to where TIFF files are located, default is C:\Temp\MODI Images.
$Filename = InputBox ( "Filename to Operate On", "Please enter the filename of the file you wish to operate on. There is no need to include the .tif extension. Then click Ok or press Enter.", "", "", 300, 200 ); Request filename of TIFF file to operate on, and assign to variable.
$Pages = InputBox ( "Number of Pages in File", "Please enter the number of pages in the file "&$Filename&" and click Ok or press Enter.", "", "", 300, 200 ); Request number of pages in TIFF file, and assign to variable.
$Logfile = InputBox ( "Produce Logfile?", "Do you wish to have a logfile produced by exiftool, after it operates on "&$Filename&"? Y/N", "N", "", 300, 200 ); If Yes, then run the command exiftool -a -u -g1 on the TIFF file and pipe that to a text file.

$FileList = _FileListToArray ( $FilePath, "*.tif", 1 ); Variable used to hold the array of TIFF files found, the $iFlag=1 parameter restricts the search to files only (no folders)

For $i = 1 To UBound ($FileList)-1
ShellExecuteWait ( $exiftoolPath&"exiftool.exe", "-a -u -g1"&$FileList[$i]&">"&$FileList[$i]&".txt", "", "", @SW_HIDE )
Next

Exit; Exits.

Basically, the problem is in the last ShellExecuteWait line. The purpose of this code is to:

1. Create an array and place into it the names of all TIFF files found in a folder.

2. For each TIFF file, run the command: exiftool.exe -a -u -g1 (filename.tif) >(filename.txt)

Problem is, it doesn't actually work. Leaving the code as above, I run the script - nothing happens, no files are produced, no windows pop up on screen. Nothing. Adding 2 spaces in the ShellExecuteWait line:

ShellExecuteWait ( $exiftoolPath&"exiftool.exe", "-a -u -g1 "&$FileList[$i]&" >"&$FileList[$i]&".txt", "", "", @SW_HIDE )

makes no difference either. If I then remove the -1 from the For $i = 1 to Ubound line, I receive the following error:

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Can anyone spot what is wrong here?

Thanks,

CM

Edited by romulous
Link to comment
Share on other sites

Hi,

Not really looked throught the whole code..

But exiftool.exe would be looking for the tif file in what directory and puting the output in what directory?

Also I'd try using the $FileList[0] instead of UBound ($FileList)-1

For $i = 1 To $FileList[0]
    Local $sPath = $FilePath & "\" & $FileList[$i]
    ShellExecuteWait($exiftoolPath & "exiftool.exe",  "-a -u -g1 " & $sPath & " >" & $sPath & ".txt", "", "", @SW_HIDE )
Next

Cheers

Link to comment
Share on other sites

Hi,

Not really looked throught the whole code..

But exiftool.exe would be looking for the tif file in what directory and puting the output in what directory?

Also I'd try using the $FileList[0] instead of UBound ($FileList)-1

For $i = 1 To $FileList[0]
    Local $sPath = $FilePath & "\" & $FileList[$i]
    ShellExecuteWait($exiftoolPath & "exiftool.exe",  "-a -u -g1 " & $sPath & " >" & $sPath & ".txt", "", "", @SW_HIDE )
Next

Cheers

I think smashly in on to the right idea. _FileListToArray() does not put the full path in the array. So the effective path to each .tif file is: $FilePath & "\" & $FileList[$i]

Another problem can be parsing file names with spaces and punctuation in them. To avoid getting into single/double quotes hell on your parameters, try this:

$sPath = FileGetShortName($FilePath & "\" & $FileList[$i])

The 8.3 formatted short name can always be passed without worrying about quotation.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...