Open and perform action on several files

Trying do automate a batch conversation of files.
Have an application open

Open (not a simple open, it’s an import procedure) file A from folder A.

Save and close the file (actually there are several files created and open as result of importing the file A)

Repeat the above for file B, file C and so on. All from same folder A.

What having trouble with is how to perform this loop for each file in the folder.

I have tried to use the Directory.GetFiles and also the For Each Row having the file names Inna an Excel-file.

In the Open (import) The file name (including file extension) of file to be opened should be filled in and this of course needs to be a different name each time. If this could be from all the files in a folder or from an Excel-file. Also if possible to have it verify If correct file type in the case of using all files in folder.

Thank you for any advice on how to solve this.

Best regards
/Jonas

Hi,
What about using “For Each File in Folder” snippet?
image

Cheers,
Josef

Hi Josef,

Thank you very much for your reply.

Yes the “For Each File in Folder” might be the way to go. Thank you for suggesting that.

Question:
For the application I’m automating (Autodesk Inventor) I need to use the file name including the file extension.
I have tried to use … file … as the input (variable) for file to open, but it includes the file path.
How do I filter (trim) away the file path, and only keep the file name including file extension (.DWG)

Thanks
/Jonas

Use Path.GetFileName(file).

So assign fileName = Path.GetFileName(file)

and then use fileName for the file name.

@Jonas_Axelsson,

Use Directory.GetFiles it will stored in Array(Of String), So Just you can use For Each Activity to Expand the Files name inside the folder.
:slightly_smiling_face::slightly_smiling_face:

Regard,

Hi ulaimins,

assign fileName = Path.GetFileName(file)

worked :slight_smile:

So far I have only tested it to automate creating new files using Notepad.

I will now use the solution for the application Inventor.

Update this on how it goes.

Thank you very much.

/Jonas

Hi deepikamurugesan,

Thank you for your reply, but I’m still a Rocky didn’t understand how to implement this.

The assign fileName = Path.GetFileName(file) seemed to work though.

Thanks
/Jonas

Hi,
Related to this.

If I have files of different file type in this folder. How can I have it to only look for a specified file type. It would make it easier to not have to split the files into several folders and instead make it only care about a specified file type.

Thank you very much for suggestions on this.
/Jonas

hello @Jonas_Axelsson you can use this- Directory.GetFiles(“SomePath”,“*.xlsx”) this will filter out non xlsx files

1 Like

@AkshaySandhu that’s fantastic i will try that. it will make the automation I try so much easier, thanks
/Jonas