Processing multiple files in a directory

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Richard959
Newbie
Posts: 1
Joined: Fri Jan 30, 2004 3:36 am

Processing multiple files in a directory

Post by Richard959 » Fri Jan 30, 2004 3:48 am

I am using an application from Xerox to convert files from its scanned file format (.rdo) to pdf. I would like to automate it to process an entire directory of rdo files. Each file take several minutes to process. We use windows 2000 and acrobat 5.0. Writing the basic script to open the rdo - and export it to pdf is straight forward but I have no idea how to script the process of opening and exporting multiple files. I have no experience with visual basic. I am hoping to find a way using Macro Scheduler commands. Any ideas would be greatly appreciated.
Thanks

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sat Jan 31, 2004 1:58 am

Quick answer is YES you will be able to do this in Macro Scheduler.

No time to provide example right now, but someone may be back with an answer before me. Just wanted to let you know Macro Scheduler is the correct answer for you.

Here is extract from Help on Separate> command:
=========================================
Separate>list,delimiter,returnvar

Separate takes a list, a delimiter and returns the elements of the list. The command returns a number of variables, one for each list element, each with the suffix "_n" where n is the index of the element in the list. The variable names are determined by the name given in returnvar. e.g. returnvar_1, returnvar_2, etc. Also returned is the number of elements in the list, in returnvar_count.

Abbreviation : SEP

Example

GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
==============================

Use this with Run Program> where Run Program would replace the example Message. Assumes you can pass filenames to your conversion program. Sumething like:

Use Position and MidStr to separate filename core from filename extension.
Run Program>c:\folder\converter.exe c:\data\rdo\file_names_%k%c:\data\pdf\%filenamecore%.pef
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

Re: Processing multiple files in a directory

Post by macroman » Wed May 11, 2016 10:05 am

this doesn't work too well if directory is empty....

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Re: Processing multiple files in a directory

Post by Jerry Thomas » Wed May 11, 2016 3:45 pm

To check for empty folder...

Code: Select all

GetFileList>c:\temp\*.*,files 

//  ADDED
Length>Files,FilelistLen
If>FileListLen>0
(then use script from Bob)
//

  Separate>files,;,file_names 
  MessageModal>Num Files: %file_names_count% 
  Let>k=0 
  Repeat>k 
  Let>k=k+1 
  Message>file_names_%k% 
  Until>k,file_names_count
else
  MDL>No files found
endif
Thanks,
Jerry

[email protected]

macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

Re: Processing multiple files in a directory

Post by macroman » Wed May 11, 2016 6:18 pm

awesome!

macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

Re: Processing multiple files in a directory

Post by macroman » Wed Jun 08, 2016 7:40 pm

Jerry Thomas wrote:To check for empty folder...

Code: Select all

GetFileList>c:\temp\*.*,files 

//  ADDED
Length>Files,FilelistLen
If>FileListLen>0
(then use script from Bob)
//

  Separate>files,;,file_names 
  MessageModal>Num Files: %file_names_count% 
  Let>k=0 
  Repeat>k 
  Let>k=k+1 
  Message>file_names_%k% 
  Until>k,file_names_count
else
  MDL>No files found
endif
instead of

Code: Select all

 *.*
how do specify multiple extensions such as

Code: Select all

*.exe and *.com and *.bat
?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Re: Processing multiple files in a directory

Post by Jerry Thomas » Wed Jun 08, 2016 8:19 pm

There are a couple of things you might have been trying to do so I show 2 techniques
You should be able to run this as is since I used c:\Windows

Code: Select all

// Get the list of all files
GetFileList>c:\Windows\*.*,files

// Convert to upper case
UpperCase>files,files

// This is the position of the first occurrence - NOT the number of occurrences
Position>.JPG,files,1,JPG_Exists
Position>.EXE,files,1,EXE_Exists

// If 1 or more of the files types exist...
If>{(%JPG_Exists%>0) or (%EXE_Exists%>0)
  // break the string of files names into an array
  Separate>files,;,file_names
  MessageModal>Total number of files: %file_names_count%
  
  // Counters
  Let>k=0
  Let>EXE_Count=0
  Let>JPG_Count=0
  
  // Loop through all of the file names
  Repeat>k
    // increment the counter
    Let>k=k+1
    
    // Get the extension of the file
    ExtractFileExt>file_names_%k%,FileExt

// ***** YOU CAN USE THIS TECHNIQUE **************
    // If file type matches what you are looking for 
    If>{(%FileExt%=".EXE") or (%FileExt%=".JPG")}
      MessageModal>file_names_%k%
    endif

// ***** OR USE THIS APPROACH  *******************
    If>FileExt=.EXE
      Let>EXE_Count=EXE_Count+1
    endif

    If>FileExt=.JPG
      Let>JPG_Count=JPG_Count+1
    endif
// ***********************************************

    // Repeat until counter = number of files
  Until>k,file_names_count
else
  MessageModal>No files found
endif

MessageModal>EXE Files: %EXE_Count%%CRLF%JPG Files: %JPG_Count%
Thanks,
Jerry

[email protected]

yadhukrishna36
Newbie
Posts: 13
Joined: Tue Oct 06, 2020 6:28 pm

Re: Processing multiple files in a directory

Post by yadhukrishna36 » Wed Jan 27, 2021 12:09 pm

Thanks all.................. :D :)

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts