Sivasankar

Open and SaveAs file with another format

14 posts in this topic

#1 ·  Posted

I am new to AutoIt . I have number of files in a folder, need to open the file one by one. Once it opened, saveas file with some other format. is it possible to achieve using AutoIt.

Please advise 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Use FileSaveDialog.

Share this post


Link to post
Share on other sites

#3 ·  Posted

5 minutes ago, Sivasankar said:

I am new to AutoIt . I have number of files in a folder, need to open the file one by one. Once it opened, saveas file with some other format. is it possible to achieve using AutoIt.

Please advise 

You need _FileListToArrayRec then For Next loop, and open the files with ShellExecute()

Share this post


Link to post
Share on other sites

#4 ·  Posted

It depends.
Which types of files (Word, Excel ...) do you need to open and save in another format (PDF ...)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

39 minutes ago, Sivasankar said:

is it possible to achieve using AutoIt.

yes.

 


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites

#6 ·  Posted

I have file with .seg format. want to convert this to .tiff format

Share this post


Link to post
Share on other sites

#7 ·  Posted

where is your code???


ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites

#8 ·  Posted

@rootx : Thanks for your reply, I got the list of files from folder using FileListToArrayRec. then opened the each document using For Next loop, now I need to do SaveAs the file with same name  but different format. I am facing problem like couldn't able to open SaveAs dialog window. 

Here I tried to convert file docx to rtf. but my actual requirement is convert file .SEG to TIFF format

@232showtime: Please check below code, correct me if iam wrong,

 

#include <Array.au3> 
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>
#include <FileConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $sAutoItDir = StringLeft(@ScriptDir, StringInStr(@ScriptDir, "\", Default, -1))
    If StringRight($sAutoItDir, 5) = "beta\" Then
        $sAutoItDir = StringTrimRight($sAutoItDir, 5)
    EndIf
    ConsoleWrite($sAutoItDir & @CRLF)

$aArray = _FileListToArrayRec($sAutoItDir, "*.docx", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
    _ArrayDisplay($aArray, ".Docx Files")

For $i =1 to $aArray[0]
   MsgBox($MB_SYSTEMMODAL, "", "Count down!" & @CRLF & $aArray[$i])
   
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
       "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
       
Local $sDocument = $aArray[$i]
Local $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
        "Error opening 'open _Word_Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
     
local $szDrive, $szDir, $szFName, $szExt
_PathSplit($aArray[$i], $szDrive, $szDir, $szFName, $szExt)
MsgBox(0, $aArray[$i], $szDrive & $szDir);

Local $sMessage = "Choose a filename."
;Local $sFileSaveDialog = FileSaveDialog($sMessage, "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Scripts (*.xlsx)", $FD_PATHMUSTEXIST,$szFName)
Local $sFileSaveDialog = FileSaveDialog($sMessage, $szDrive & $szDir & "te" , "Scripts (*.rtf)", $FD_PATHMUSTEXIST,$szFName)

   If @error Then
      MsgBox($MB_SYSTEMMODAL, "", "No file was saved.")
   Else
      Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSE, -1))
      Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSE)

      If $iExtension Then       
         If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".rtf") Then $sFileSaveDialog &= ".rtf"
      Else
         $sFileSaveDialog &= ".rtf"
      EndIf
      
      MsgBox($MB_SYSTEMMODAL, "", "You saved the following file:" & @CRLF & $sFileSaveDialog)
   EndIf

Next
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

22 hours ago, Sivasankar said:

Once it opened, saveas file with some other format. is it possible to achieve using AutoIt.

Have you tried having it this way? Other formats were added in "FileSaveDialog()":

Local $sFileSaveDialog = FileSaveDialog($sMessage, $szDrive & $szDir & "te" , "TIFF (*.tiff)|JPEG (*.jpeg)|PNG (*.png)", $FD_PATHMUSTEXIST,$szFName)

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

You can't use FileSaveDialog in this way. To save a document from Word you need to use _Word_DocSaveAs or _Word_DocExport.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

BTW: You shouldn't have _Word_Create inside the

For $i =1 to $aArray[0]

loop. Open Word one time at the top of your script and close it before the script ends.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

Please ignore above code. My requirement is, convert Mainframe file into image format using ELIXIR tool, but manually it takes too long. So plan to achieve the scenario with AutoIT. 

1. Get all files from a folder

2. Open each .SEG format file in "ELIXIR" tool

3. Then SaveAs the file with .TIFF format in another location. 

Please advise

Share this post


Link to post
Share on other sites

#13 ·  Posted

I'm not familiar with the tool, and all the docs I've seen for what I "think" it might be...it looks like a fairly old application.  I would look through the documentation to see if there are any command-line operations to execute the tool and do the conversion.  That may be the easiest and/or most elegant way to automate it.    Otherwise, you can try automating keystrokes and clicks based on keyboard shortcuts and window location.  What would be ideal is if you can use the Au3Info tool included with AutoIt to identify the controls in the GUI and use the more robust Control* functions to automate the GUI...much less room for error versus sending keystrokes and mouse clicks.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

On 17/5/2017 at 7:41 AM, Sivasankar said:

Please ignore above code. My requirement is, convert Mainframe file into image format using ELIXIR tool, but manually it takes too long. So plan to achieve the scenario with AutoIT. 

1. Get all files from a folder

2. Open each .SEG format file in "ELIXIR" tool

3. Then SaveAs the file with .TIFF format in another location. 

Please advise

1. use _FileListToArrayRec to get all file.... .SEG

2. Inside the loop FOR ... NEXT execute ELIXIR tool to convert it one by one

3 Put an If control to chek if the file is converted and exist than copy it with filecopy

PS: you need to set ELIXIR global varible in windows and test it with cmd if everithing is ok you can use shellexecutewait or Runwait

Edited by rootx

Share this post


Link to post
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