Jump to content
Macro Express Forums

Rearrange file name


Recommended Posts

Hi. I have been using Macro Express for years on simple things. I now have a problem I'm sure I can do with a macro. I have several files that I need to alter the name. "LastName_FirstName_Account-Number Discription Text_MMDDYY.pdf" (Notice the underscore). Anyway, I want to rearrange the order if I can. I want to change it to "Account-Number LastName, FirstName Discription Text YYYY-MM-DD.pdf". Is this possible or am I way over my head? Thanks.

Link to comment
Share on other sites

This requires quite a bit of string manipulation, but it can be done. Here is how I would approach this task. I have inserted the first part of the macro and description that should give you an idea.


1. Variable Set String %T1% - save the filename to a variable such as T1

2. Variable Set Integer %N1% from Position of Text in Variable %T1% - Use this command to find the position of the first _ character.

3. Variable Modify String: Copy Part of %T1% to %T2% - Copy part of the string to T2. The number of characters to copy is N1. This saves the string of LastName_ to T2.


4. Variable Modify String: Delete Part of %T2% - Delete the last character so that T2 is LastName.

5. Variable Modify String: Delete Part of %T1% - Delete the LastName_ string from the original T1 string of LastName_FirstName_Account-Number Discription Text_MMDDYY.pdf. Now T1 = FirstName_Account-Number Discription Text_MMDDYY.pdf and T2 = LastName.


Repeat the process to save FirstName to a variable such as T3.

Repeat again to extract the account number. Hopefully the account number is always the same number of characters, or there may not be a simple way to split the account number from the Description.


You'll need to do string manipulation with the date as well. Save the 6 date characters to a variable. Then extract each set of two and save to individual variables.


Then use the Text Type command to string your new file name together %T3%%T2%,etc.pdf.



Stan Jones

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...