license & Scripting Questions

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
super8
Newbie
Posts: 1
Joined: Mon Jul 16, 2012 12:05 am

license & Scripting Questions

Post by super8 » Mon Jul 16, 2012 12:13 am

I’ve been working with macro scheduler for the last few days and have been able to almost complete my macro script. Before I purchase macro scheduler though I have a few questions regarding licensing and scripting.

Questions:

1 -How many computers can I install the software per license and how easily can I move my license from computer to computer.


2 - I have a loop in my script which allows me to get all folders within a folder.

Let>GFL_TYPE=1

GetFileList>C:\Users\temp\*.*,folder_list,;


Separate>folder_list,;,folders
If>folders_count>0
Let>fldr=0
Repeat>fldr
Let>fldr=fldr+1
Let>this_folder=folders_%fldr%


Until>fldr=folders_count
Endif

This returns the full folder path for the variable ‘this_folder’, but is there a way to return simply the folder name within this loop ? Thus putting something in the loop to simply return the folder name in a separate variable.


3 - The last issue I’m having with my macro is that I need to count the number of lines per file then append the number to the file name. is that possible?


Thank you for your time and your wonderful software. :D

User avatar
Marcus Tettmar
Site Admin
Posts: 7393
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jul 16, 2012 3:56 pm

Hi,

1. One per user (depends on how many licenses you buy)

2. Use the ExtractFileName function, or parse by "/"

3. Read a file in with ReadFile, count line numbers using RegEx or a repeat/until loop, construct filename with the result.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

Post by hoangvo81 » Wed Aug 01, 2012 5:30 pm

can you demonstrate how to use extract file name to get a folder name?
Below is what i would do. Using stringreplace will help as you already know the starting folder path.

Code: Select all

Let>GFL_TYPE=1 

GetFileList>C:\Users\temp\*.*,folder_list,; 


Separate>folder_list,;,folders 
If>folders_count>0 
Let>fldr=0 
Repeat>fldr 
Let>fldr=fldr+1 
stringreplace>folders_%fldr%,c:\Users\temp\,,tmp
Let>this_folder=tmp

//additional code???
Until>fldr=folders_count 
Endif 

problem here is : Let>this_folder=tmp
the this_folder will be replace each time it go through the list, so i m assuming that theres additional code below that line.
stringreplace will replace the path c:\Users\temp\, in the folder_%fldr% with an empty value and assigned it to tmp, which you can then asssign to 'this_folder' to hold only the folder name.

hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

Post by hoangvo81 » Wed Aug 01, 2012 6:27 pm

i m not sure if this is what you are looking for for number 3 and you might have to play or google regex patterns,

Code: Select all


Let>GFL_TYPE=0
let>initFolder=c:\Users\Temp\
GetFileList>%initFolder%*.*,files,;
Separate>files,;,file
let>x=0
let>pattern=\r\n
repeat>x
  add>x,1
    ExtractFileName>file_%x%,fName
    ExtractFileExt>file_%x%,fExt
    StringReplace>fname,%fExt%,,fName
    readfile>file_%x%,strFile
    RegEx>pattern,strFile,0,matches,n,0,,,
    let>newfile=%initFolder%%fname%%n%%fext%
    RenameFile>file_%x%,%newfile%    
Until>x=file_count

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