vsthakar Posted June 18, 2009 Report Share Posted June 18, 2009 Hi. I am new to Macro Express 3. I have been through the help files and tutorials to get my feet wet and wanted to learn about macros with a very simple task -- how do I rename 10 files in a directory to the 10 names listed in a text file. I understand I have to create a variable from the text file but could someone show me the exact commands to to put in the scripting editor to have the macro take each name from the text file and rename each file in the directory? I see how to rename a specific file but not the entire list. Thanks in advance for any help. Vijay Quote Link to comment Share on other sites More sharing options...
stan Posted June 18, 2009 Report Share Posted June 18, 2009 Here is how I would approach this: 1. Variable Set Integer %N1% to 0 2. Repeat with Folder 3. Variable Set From File Path 4. Variable Set From File Path 5. Variable Modify Integer: Inc (%N1%) 6. Text File Begin Process: "renamefiles.txt" 7. Rename File or Files: "%T1%" 8. Text File End Process 9. Repeat End Below is a description of what each step does: 1. Set an integer variable to 0 2. Select the folder that contains the files to be renamed. Select the full path and save the information to a variable such as T1 3. Set the Drive letter of file T1 to a variable such as T2 4. Set the file path of file T1 to another variable such as T3 5. Increment the integer value by one each time through the repeat loop 6. This reads the file name from the text file and saves it to a variable such as T4. Start processing on variable N1 and only process one record. The first time through the repeat loop, variable N1 is set to 1, so it will grab the first line of the text file. 7. Rename the file T1. Rename it as %T2%%T3%%T4% - This provides the original drive and file path plus the new file name taken from the .txt file. 8. End the Text file Process loop 9. Close the Repeat loop. The macro will rename the first file in the folder with the first name in the .txt file. It repeats to rename the second file with the second name in the .txt file and so on. You can modify this if you want to save the files to a new location. But, here is something to keep in mind. The Repeat with Folder command starts with the first file that Windows presents. This may or may not be the first file listed in Windows Explorer. Quote Link to comment Share on other sites More sharing options...
vsthakar Posted July 2, 2009 Author Report Share Posted July 2, 2009 Thank you so much for your help. The macro worked after I used your instructions. Now on to more complex macros! Vijay Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.